diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java index e0fe4912c..e5c03d3f1 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java @@ -1,5 +1,10 @@ package org.schabi.newpipe.extractor; +import java.io.IOException; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import org.schabi.newpipe.extractor.downloader.Downloader; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; @@ -8,11 +13,6 @@ import org.schabi.newpipe.extractor.localization.ContentCountry; import org.schabi.newpipe.extractor.localization.Localization; import org.schabi.newpipe.extractor.localization.TimeAgoParser; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; -import java.io.Serializable; - public abstract class Extractor{ /** * {@link StreamingService} currently related to this extractor.
@@ -93,6 +93,11 @@ public abstract class Extractor{ public String getUrl() throws ParsingException { return linkHandler.getUrl(); } + + @Nonnull + public String getBaseUrl() throws ParsingException { + return linkHandler.getBaseUrl(); + } @Nonnull public StreamingService getService() { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java index c28bc5c83..525105134 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java @@ -2,6 +2,9 @@ package org.schabi.newpipe.extractor.linkhandler; import java.io.Serializable; +import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.utils.Utils; + public class LinkHandler implements Serializable { protected final String originalUrl; protected final String url; @@ -28,4 +31,8 @@ public class LinkHandler implements Serializable { public String getId() { return id; } + + public String getBaseUrl() throws ParsingException { + return Utils.getBaseUrl(url); + } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java index 3c42cd396..9d247abc2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java @@ -122,7 +122,7 @@ public class PeertubeService extends StreamingService { return instance.getUrl(); } - public void setInstance(PeertubeInstance instance) throws IOException { + public void setInstance(PeertubeInstance instance) { this.instance = instance; this.getServiceInfo().setName(instance.getName()); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java index b179ae13f..8b214670c 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java @@ -16,7 +16,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.utils.JsonUtils; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Parser.RegexException; -import org.schabi.newpipe.extractor.utils.Utils; import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonObject; @@ -38,7 +37,7 @@ public class PeertubeChannelExtractor extends ChannelExtractor { public PeertubeChannelExtractor(StreamingService service, ListLinkHandler linkHandler) throws ParsingException { super(service, linkHandler); - this.baseUrl = Utils.getBaseUrl(getUrl()); + this.baseUrl = getBaseUrl(); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsExtractor.java index f49c76736..b7aba4fac 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsExtractor.java @@ -56,7 +56,7 @@ public class PeertubeCommentsExtractor extends CommentsExtractor { for(Object c: contents) { if(c instanceof JsonObject) { final JsonObject item = (JsonObject) c; - PeertubeCommentsInfoItemExtractor extractor = new PeertubeCommentsInfoItemExtractor(item, pageUrl); + PeertubeCommentsInfoItemExtractor extractor = new PeertubeCommentsInfoItemExtractor(item, this); collector.commit(extractor); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsInfoItemExtractor.java index 886dcda8f..edb59e1fe 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsInfoItemExtractor.java @@ -8,7 +8,6 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.localization.DateWrapper; import org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper; import org.schabi.newpipe.extractor.utils.JsonUtils; -import org.schabi.newpipe.extractor.utils.Utils; import com.grack.nanojson.JsonObject; @@ -19,10 +18,10 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac private final String url; private final String baseUrl; - public PeertubeCommentsInfoItemExtractor(JsonObject item, String url) throws ParsingException { + public PeertubeCommentsInfoItemExtractor(JsonObject item, PeertubeCommentsExtractor extractor) throws ParsingException { this.item = item; - this.url = url; - this.baseUrl = Utils.getBaseUrl(url); + this.url = extractor.getUrl(); + this.baseUrl = extractor.getBaseUrl(); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSearchExtractor.java index ec8786deb..ff021f732 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSearchExtractor.java @@ -17,7 +17,6 @@ import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.utils.JsonUtils; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Parser.RegexException; -import org.schabi.newpipe.extractor.utils.Utils; import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonObject; @@ -59,7 +58,7 @@ public class PeertubeSearchExtractor extends SearchExtractor { throw new ParsingException("unable to extract search info", e); } - String baseUrl = Utils.getBaseUrl(getUrl()); + String baseUrl = getBaseUrl(); for(Object c: contents) { if(c instanceof JsonObject) { final JsonObject item = (JsonObject) c; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java index 3ed260c5e..d8d0de005 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java @@ -45,7 +45,7 @@ public class PeertubeStreamExtractor extends StreamExtractor { public PeertubeStreamExtractor(StreamingService service, LinkHandler linkHandler) throws ParsingException { super(service, linkHandler); - this.baseUrl = Utils.getBaseUrl(getUrl()); + this.baseUrl = getBaseUrl(); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeTrendingExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeTrendingExtractor.java index df0fb2437..0ff340f29 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeTrendingExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeTrendingExtractor.java @@ -15,7 +15,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.utils.JsonUtils; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Parser.RegexException; -import org.schabi.newpipe.extractor.utils.Utils; import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonObject; @@ -54,7 +53,7 @@ public class PeertubeTrendingExtractor extends KioskExtractor { throw new ParsingException("unable to extract kiosk info", e); } - String baseUrl = Utils.getBaseUrl(getUrl()); + String baseUrl = getBaseUrl(); for(Object c: contents) { if(c instanceof JsonObject) { final JsonObject item = (JsonObject) c;