File tree Expand file tree Collapse file tree
extractor/src/main/java/org/schabi/newpipe/extractor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .schabi .newpipe .extractor ;
22
3+ import org .schabi .newpipe .extractor .exceptions .ExtractionException ;
34import org .schabi .newpipe .extractor .linkhandler .LinkHandler ;
45
56import java .io .Serializable ;
@@ -72,6 +73,15 @@ public int getServiceId() {
7273 return serviceId ;
7374 }
7475
76+ public StreamingService getService () {
77+ try {
78+ return NewPipe .getService (serviceId );
79+ } catch (final ExtractionException e ) {
80+ // this should be unreachable, as serviceId certainly refers to a valid service
81+ throw new RuntimeException ("Info object has invalid service id" , e );
82+ }
83+ }
84+
7585 public String getId () {
7686 return id ;
7787 }
Original file line number Diff line number Diff line change @@ -99,7 +99,6 @@ public static StreamingService getServiceByUrl(String url) throws ExtractionExce
9999
100100 public static int getIdOfService (String serviceName ) {
101101 try {
102- //noinspection ConstantConditions
103102 return getService (serviceName ).getServiceId ();
104103 } catch (ExtractionException ignored ) {
105104 return -1 ;
@@ -108,7 +107,6 @@ public static int getIdOfService(String serviceName) {
108107
109108 public static String getNameOfService (int id ) {
110109 try {
111- //noinspection ConstantConditions
112110 return getService (id ).getServiceInfo ().getName ();
113111 } catch (Exception e ) {
114112 System .err .println ("Service id not known" );
You can’t perform that action at this time.
0 commit comments