Skip to content

Commit 13f1927

Browse files
committed
Add utility method getService() to Info object
1 parent 0ad51e7 commit 13f1927

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • extractor/src/main/java/org/schabi/newpipe/extractor

extractor/src/main/java/org/schabi/newpipe/extractor/Info.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.extractor;
22

3+
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
34
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
45

56
import 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
}

0 commit comments

Comments
 (0)