[YouTube] Fix NPE when getting channel header for videos channel tab

This commit is contained in:
AudricV 2024-07-24 19:17:28 +02:00
parent 8be64574e4
commit 10704dfc94
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
2 changed files with 10 additions and 6 deletions

View File

@ -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":

View File

@ -60,7 +60,7 @@ public class YoutubeChannelTabExtractor extends ChannelTabExtractor {
@Nullable
private String visitorData;
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
private Optional<YoutubeChannelHelper.ChannelHeader> channelHeader;
protected Optional<YoutubeChannelHelper.ChannelHeader> 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<YoutubeChannelHelper.ChannelHeader> 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;
}