Add utility method getService() to Info object

This commit is contained in:
Stypox 2021-06-05 14:14:19 +02:00
parent 0ad51e76fb
commit 13f192704d
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
import java.io.Serializable;
@ -72,6 +73,15 @@ public abstract class Info implements Serializable {
return serviceId;
}
public StreamingService getService() {
try {
return NewPipe.getService(serviceId);
} catch (final ExtractionException e) {
// this should be unreachable, as serviceId certainly refers to a valid service
throw new RuntimeException("Info object has invalid service id", e);
}
}
public String getId() {
return id;
}