From ec71642eff35ec5abdbe384532aaa06b84be8930 Mon Sep 17 00:00:00 2001 From: wispl Date: Sun, 4 Aug 2024 19:46:51 -0400 Subject: [PATCH] [Youtube] add ytmusic linked playlist --- ...tubeMusicSongOrVideoInfoItemExtractor.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSongOrVideoInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSongOrVideoInfoItemExtractor.java index 11b220288c..f470463184 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSongOrVideoInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSongOrVideoInfoItemExtractor.java @@ -174,4 +174,26 @@ public List getThumbnails() throws ParsingException { throw new ParsingException("Could not get thumbnails", e); } } + + @Nonnull + public String getPlaylist() { + if (searchType.equals(MUSIC_SONGS)) { + for (final Object item : descriptionElements) { + final JsonObject browseEndpoint = ((JsonObject) item) + .getObject("navigationEndpoint") + .getObject("browseEndpoint"); + + final String type = browseEndpoint + .getObject("browseEndpointContextSupportedConfigs") + .getObject("browseEndpointContextMusicConfig") + .getString("pageType"); + + if (type != null && type.equals("MUSIC_PAGE_TYPE_ALBUM")) { + return browseEndpoint.getString("browseId"); + } + } + } + // handles singles, video, and others which may not belong in playlist + return ""; + } }