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 2f02a460b..974c4555e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java @@ -13,7 +13,19 @@ public abstract class Info implements Serializable { * e.g. Youtube: https://www.youtube.com/watch?v=RER5qCTzZ7 > RER5qCTzZ7 */ private final String id; + /** + * Different than the {@link #originalUrl} in the sense that it may be set as a cleaned url. + * + * @see UrlIdHandler#cleanUrl(String) + * @see Extractor#getCleanUrl() + */ private final String url; + /** + * The url used to start the extraction of this {@link Info} object. + * + * @see Extractor#getOriginalUrl() + */ + private final String originalUrl; private final String name; private final List errors = new ArrayList<>(); @@ -26,16 +38,18 @@ public abstract class Info implements Serializable { this.errors.addAll(errors); } - public Info(int serviceId, String id, String url, String name) { + public Info(int serviceId, String id, String url, String originalUrl, String name) { this.serviceId = serviceId; this.id = id; this.url = url; + this.originalUrl = originalUrl; this.name = name; } @Override public String toString() { - return getClass().getSimpleName() + "[url=\"" + url + "\", name=\"" + name + "\"]"; + final String ifDifferentString = !url.equals(originalUrl) ? " (originalUrl=\"" + originalUrl + "\")" : ""; + return getClass().getSimpleName() + "[url=\"" + url + "\"" + ifDifferentString + ", name=\"" + name + "\"]"; } public int getServiceId() { @@ -50,6 +64,10 @@ public abstract class Info implements Serializable { return url; } + public String getOriginalUrl() { + return originalUrl; + } + public String getName() { return name; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java index 74cbcc1f2..1b8ce1d96 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/ListInfo.java @@ -6,8 +6,8 @@ public abstract class ListInfo extends Info { private List relatedItems; private String nextPageUrl = null; - public ListInfo(int serviceId, String id, String url, String name) { - super(serviceId, id, url, name); + public ListInfo(int serviceId, String id, String url, String originalUrl, String name) { + super(serviceId, id, url, originalUrl, name); } public List getRelatedItems() { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java index 760e3efa1..1691f9544 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java @@ -32,8 +32,8 @@ import java.io.IOException; public class ChannelInfo extends ListInfo { - public ChannelInfo(int serviceId, String url, String id, String name) { - super(serviceId, id, url, name); + public ChannelInfo(int serviceId, String id, String url, String originalUrl, String name) { + super(serviceId, id, url, originalUrl, name); } public static ChannelInfo getInfo(String url) throws IOException, ExtractionException { @@ -55,10 +55,11 @@ public class ChannelInfo extends ListInfo { // important data int serviceId = extractor.getServiceId(); String url = extractor.getCleanUrl(); + String originalUrl = extractor.getOriginalUrl(); String id = extractor.getId(); String name = extractor.getName(); - ChannelInfo info = new ChannelInfo(serviceId, url, id, name); + ChannelInfo info = new ChannelInfo(serviceId, id, url, originalUrl, name); try { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java index 4f98f77cb..550b8b577 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java @@ -32,8 +32,8 @@ import java.io.IOException; public class KioskInfo extends ListInfo { - private KioskInfo(int serviceId, String id, String url, String name) { - super(serviceId, id, url, name); + private KioskInfo(int serviceId, String id, String url, String originalUrl, String name) { + super(serviceId, id, url, originalUrl, name); } public static ListExtractor.InfoItemsPage getMoreItems(StreamingService service, @@ -72,8 +72,9 @@ public class KioskInfo extends ListInfo { String name = extractor.getName(); String id = extractor.getId(); String url = extractor.getCleanUrl(); + String originalUrl = extractor.getOriginalUrl(); - KioskInfo info = new KioskInfo(serviceId, id, name, url); + KioskInfo info = new KioskInfo(serviceId, id, url, originalUrl, name); final ListExtractor.InfoItemsPage itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor); info.setRelatedItems(itemsPage.getItems()); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java index 24bd25b6f..c8910651d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java @@ -12,8 +12,8 @@ import java.io.IOException; public class PlaylistInfo extends ListInfo { - public PlaylistInfo(int serviceId, String id, String url, String name) { - super(serviceId, id, url, name); + public PlaylistInfo(int serviceId, String id, String url, String originalUrl, String name) { + super(serviceId, id, url, originalUrl, name); } public static PlaylistInfo getInfo(String url) throws IOException, ExtractionException { @@ -39,9 +39,10 @@ public class PlaylistInfo extends ListInfo { int serviceId = extractor.getServiceId(); String url = extractor.getCleanUrl(); + String originalUrl = extractor.getOriginalUrl(); String id = extractor.getId(); String name = extractor.getName(); - PlaylistInfo info = new PlaylistInfo(serviceId, id, url, name); + PlaylistInfo info = new PlaylistInfo(serviceId, id, url, originalUrl, name); try { info.setStreamCount(extractor.getStreamCount()); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java index 75fc5a6aa..716afa4b9 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java @@ -41,8 +41,8 @@ public class StreamInfo extends Info { } } - public StreamInfo(int serviceId, String url, StreamType streamType, String id, String name, int ageLimit) { - super(serviceId, id, url, name); + public StreamInfo(int serviceId, String url, String originalUrl, StreamType streamType, String id, String name, int ageLimit) { + super(serviceId, id, url, originalUrl, name); this.streamType = streamType; this.ageLimit = ageLimit; } @@ -86,6 +86,7 @@ public class StreamInfo extends Info { int serviceId = extractor.getServiceId(); String url = extractor.getCleanUrl(); + String originalUrl = extractor.getOriginalUrl(); StreamType streamType = extractor.getStreamType(); String id = extractor.getId(); String name = extractor.getName(); @@ -99,7 +100,7 @@ public class StreamInfo extends Info { throw new ExtractionException("Some important stream information was not given."); } - return new StreamInfo(serviceId, url, streamType, id, name, ageLimit); + return new StreamInfo(serviceId, url, originalUrl, streamType, id, name, ageLimit); } private static StreamInfo extractStreams(StreamInfo streamInfo, StreamExtractor extractor) throws ExtractionException {