From 10704dfc94bff1023912ea0003befae7f7186199 Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Wed, 24 Jul 2024 19:17:28 +0200 Subject: [PATCH] [YouTube] Fix NPE when getting channel header for videos channel tab --- .../youtube/extractors/YoutubeChannelExtractor.java | 6 +++--- .../youtube/extractors/YoutubeChannelTabExtractor.java | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) 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 776164f89..50ebb96a3 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 @@ -336,8 +336,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor { } } - // The description is cut and the original one can be only accessed from the About tab - return jsonResponse.getObject("title") + return jsonResponse.getObject(METADATA) .getObject("channelMetadataRenderer") .getString("description"); } catch (final Exception e) { @@ -432,7 +431,8 @@ public class YoutubeChannelExtractor extends ChannelExtractor { channelId, ChannelTabs.VIDEOS, (service, linkHandler) -> new VideosTabExtractor( - service, linkHandler, tabRenderer, name, id, url))); + service, linkHandler, tabRenderer, channelHeader, + name, id, url))); break; case "shorts": diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabExtractor.java index 44cfbde5c..6aa88c67d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabExtractor.java @@ -60,7 +60,7 @@ public class YoutubeChannelTabExtractor extends ChannelTabExtractor { @Nullable private String visitorData; @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - private Optional channelHeader; + protected Optional channelHeader; public YoutubeChannelTabExtractor(final StreamingService service, final ListLinkHandler linkHandler) { @@ -450,20 +450,24 @@ public class YoutubeChannelTabExtractor extends ChannelTabExtractor { */ public static final class VideosTabExtractor extends YoutubeChannelTabExtractor { private final JsonObject tabRenderer; - private final String channelName; private final String channelId; + private final String channelName; private final String channelUrl; VideosTabExtractor(final StreamingService service, final ListLinkHandler linkHandler, final JsonObject tabRenderer, + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") + final Optional channelHeader, final String channelName, final String channelId, final String channelUrl) { super(service, linkHandler); + this.channelHeader = channelHeader; + this.tabRenderer = tabRenderer; - this.channelName = channelName; this.channelId = channelId; + this.channelName = channelName; this.channelUrl = channelUrl; }