Skip to content

Commit ec71642

Browse files
committed
[Youtube] add ytmusic linked playlist
1 parent 6963385 commit ec71642

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSongOrVideoInfoItemExtractor.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,26 @@ public List<Image> getThumbnails() throws ParsingException {
174174
throw new ParsingException("Could not get thumbnails", e);
175175
}
176176
}
177+
178+
@Nonnull
179+
public String getPlaylist() {
180+
if (searchType.equals(MUSIC_SONGS)) {
181+
for (final Object item : descriptionElements) {
182+
final JsonObject browseEndpoint = ((JsonObject) item)
183+
.getObject("navigationEndpoint")
184+
.getObject("browseEndpoint");
185+
186+
final String type = browseEndpoint
187+
.getObject("browseEndpointContextSupportedConfigs")
188+
.getObject("browseEndpointContextMusicConfig")
189+
.getString("pageType");
190+
191+
if (type != null && type.equals("MUSIC_PAGE_TYPE_ALBUM")) {
192+
return browseEndpoint.getString("browseId");
193+
}
194+
}
195+
}
196+
// handles singles, video, and others which may not belong in playlist
197+
return "";
198+
}
177199
}

0 commit comments

Comments
 (0)