diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java index 6d529d6b6..3f54f1c2c 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java @@ -37,4 +37,7 @@ public abstract class ChannelExtractor extends ListExtractor { public abstract String getFeedUrl() throws ParsingException; public abstract long getSubscriberCount() throws ParsingException; public abstract String getDescription() throws ParsingException; + public abstract String getParentChannelName() throws ParsingException; + public abstract String getParentChannelUrl() throws ParsingException; + public abstract String getParentChannelAvatarUrl() throws ParsingException; } 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 0fc44063b..52f18eadc 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 @@ -94,16 +94,61 @@ public class ChannelInfo extends ListInfo { info.addError(e); } + try { + info.setParentChannelName(extractor.getParentChannelName()); + } catch (Exception e) { + info.addError(e); + } + + try { + info.setParentChannelUrl(extractor.getParentChannelUrl()); + } catch (Exception e) { + info.addError(e); + } + + try { + info.setParentChannelAvatarUrl(extractor.getParentChannelAvatarUrl()); + } catch (Exception e) { + info.addError(e); + } + return info; } private String avatarUrl; + private String parentChannelName; + private String parentChannelUrl; + private String parentChannelAvatarUrl; private String bannerUrl; private String feedUrl; private long subscriberCount = -1; private String description; private String[] donationLinks; + public String getParentChannelName() { + return parentChannelName; + } + + public void setParentChannelName(String parentChannelName) { + this.parentChannelName = parentChannelName; + } + + public String getParentChannelUrl() { + return parentChannelUrl; + } + + public void setParentChannelUrl(String parentChannelUrl) { + this.parentChannelUrl = parentChannelUrl; + } + + public String getParentChannelAvatarUrl() { + return parentChannelAvatarUrl; + } + + public void setParentChannelAvatarUrl(String parentChannelAvatarUrl) { + this.parentChannelAvatarUrl = parentChannelAvatarUrl; + } + public String getAvatarUrl() { return avatarUrl; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java index 4cd21c060..f11c13c22 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java @@ -52,6 +52,21 @@ public class MediaCCCConferenceExtractor extends ChannelExtractor { return null; } + @Override + public String getParentChannelName() throws ParsingException { + return ""; + } + + @Override + public String getParentChannelUrl() throws ParsingException { + return ""; + } + + @Override + public String getParentChannelAvatarUrl() throws ParsingException { + return ""; + } + @Nonnull @Override public InfoItemsPage getInitialPage() { 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 dc27be80c..c8f7f4cb3 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 @@ -75,6 +75,27 @@ public class PeertubeChannelExtractor extends ChannelExtractor { } } + @Override + public String getParentChannelName() throws ParsingException { + return JsonUtils.getString(json, "ownerAccount.name"); + } + + @Override + public String getParentChannelUrl() throws ParsingException { + return JsonUtils.getString(json, "ownerAccount.url"); + } + + @Override + public String getParentChannelAvatarUrl() throws ParsingException { + String value; + try { + value = JsonUtils.getString(json, "ownerAccount.avatar.path"); + } catch (Exception e) { + value = "/client/assets/images/default-avatar.png"; + } + return baseUrl + value; + } + @Override public InfoItemsPage getInitialPage() throws IOException, ExtractionException { super.fetchPage(); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java index a1d258b54..1068b36f1 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java @@ -83,6 +83,21 @@ public class SoundcloudChannelExtractor extends ChannelExtractor { return user.getString("description", EMPTY_STRING); } + @Override + public String getParentChannelName() throws ParsingException { + return ""; + } + + @Override + public String getParentChannelUrl() throws ParsingException { + return ""; + } + + @Override + public String getParentChannelAvatarUrl() throws ParsingException { + return ""; + } + @Nonnull @Override public InfoItemsPage getInitialPage() throws ExtractionException { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java index 38d57f95c..0e5329425 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java @@ -212,6 +212,21 @@ public class YoutubeChannelExtractor extends ChannelExtractor { } } + @Override + public String getParentChannelName() throws ParsingException { + return ""; + } + + @Override + public String getParentChannelUrl() throws ParsingException { + return ""; + } + + @Override + public String getParentChannelAvatarUrl() throws ParsingException { + return ""; + } + @Nonnull @Override public InfoItemsPage getInitialPage() throws ExtractionException { diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java index 9dc4b013e..bdab43ef8 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java @@ -84,6 +84,16 @@ public class PeertubeChannelExtractorTest { assertNotNull(extractor.getDescription()); } + @Test + public void testParentChannelName() throws ParsingException { + assertEquals("libux", extractor.getParentChannelName()); + } + + @Test + public void testParentChannelUrl() throws ParsingException { + assertEquals("https://peertube.mastodon.host/accounts/libux", extractor.getParentChannelUrl()); + } + @Test public void testAvatarUrl() throws ParsingException { assertIsSecureUrl(extractor.getAvatarUrl()); @@ -181,6 +191,16 @@ public class PeertubeChannelExtractorTest { assertNotNull(extractor.getDescription()); } + @Test + public void testParentChannelName() throws ParsingException { + assertEquals("booteille", extractor.getParentChannelName()); + } + + @Test + public void testParentChannelUrl() throws ParsingException { + assertEquals("https://peertube.mastodon.host/accounts/booteille", extractor.getParentChannelUrl()); + } + @Test public void testAvatarUrl() throws ParsingException { assertIsSecureUrl(extractor.getAvatarUrl());