From 50a17afc056cfc9ccb14a72f3ff5a944d6f9418d Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sun, 23 Dec 2018 21:52:40 +0100 Subject: [PATCH] fix issue with originalUrl --- .../src/main/java/org/schabi/newpipe/extractor/Info.java | 8 +++++++- .../org/schabi/newpipe/extractor/channel/ChannelInfo.java | 6 +++++- .../schabi/newpipe/extractor/playlist/PlaylistInfo.java | 5 +++++ .../org/schabi/newpipe/extractor/search/SearchInfo.java | 5 +++++ 4 files changed, 22 insertions(+), 2 deletions(-) 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 853fb1189..7bdb23aba 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Info.java @@ -27,7 +27,7 @@ public abstract class Info implements Serializable { * * @see Extractor#getOriginalUrl() */ - private final String originalUrl; + private String originalUrl; private final String name; private final List errors = new ArrayList<>(); @@ -62,6 +62,12 @@ public abstract class Info implements Serializable { return getClass().getSimpleName() + "[url=\"" + url + "\"" + ifDifferentString + ", name=\"" + name + "\"]"; } + // if you use an api and want to handle the website url + // overriding original url is essential + public void setOriginalUrl(String url) { + originalUrl = url; + } + public int getServiceId() { return serviceId; } 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 a848725f6..0832b601b 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 @@ -61,7 +61,11 @@ public class ChannelInfo extends ListInfo { extractor.getLinkHandler(), extractor.getName()); - + try { + info.setOriginalUrl(extractor.getOriginalUrl()); + } catch (Exception e) { + info.addError(e); + } try { info.setAvatarUrl(extractor.getAvatarUrl()); } catch (Exception e) { 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 e613c888b..978fdcdb4 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 @@ -47,6 +47,11 @@ public class PlaylistInfo extends ListInfo { extractor.getLinkHandler(), extractor.getName()); + try { + info.setOriginalUrl(extractor.getOriginalUrl()); + } catch (Exception e) { + info.addError(e); + } try { info.setStreamCount(extractor.getStreamCount()); } catch (Exception e) { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java index 474c61090..6362b6c65 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java @@ -37,6 +37,11 @@ public class SearchInfo extends ListInfo { extractor.getLinkHandler(), extractor.getSearchString()); + try { + info.setOriginalUrl(extractor.getOriginalUrl()); + } catch (Exception e) { + info.addError(e); + } try { info.searchSuggestion = extractor.getSearchSuggestion(); } catch (Exception e) {