From 13f192704dcf60baf44aa216c24253d4bfa50089 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 5 Jun 2021 14:14:19 +0200 Subject: [PATCH] Add utility method getService() to Info object --- .../main/java/org/schabi/newpipe/extractor/Info.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java b/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java index 7bdb23aba..3a1980b56 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java @@ -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; }