From 3d82eae9a921e5bf37ebea9959192a9cbca7a919 Mon Sep 17 00:00:00 2001 From: wispl Date: Sun, 4 Aug 2024 19:46:51 -0400 Subject: [PATCH 1/3] [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 11b220288..f47046318 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 class YoutubeMusicSongOrVideoInfoItemExtractor implements StreamInfoItemE 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 ""; + } } From e938ae0b14922adb4152aa60393affadb5b5c224 Mon Sep 17 00:00:00 2001 From: wispl Date: Mon, 25 Aug 2025 18:30:51 -0400 Subject: [PATCH 2/3] fixup: add implementation to base collectors and extractors --- .../YoutubeMusicSongOrVideoInfoItemExtractor.java | 4 ++-- .../newpipe/extractor/stream/StreamInfoItem.java | 9 +++++++++ .../extractor/stream/StreamInfoItemExtractor.java | 10 ++++++++++ .../extractor/stream/StreamInfoItemsCollector.java | 5 +++++ 4 files changed, 26 insertions(+), 2 deletions(-) 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 f47046318..1bba2e5ee 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 @@ -175,8 +175,8 @@ public class YoutubeMusicSongOrVideoInfoItemExtractor implements StreamInfoItemE } } - @Nonnull - public String getPlaylist() { + @Override + public String getPlaylistId() throws ParsingException { if (searchType.equals(MUSIC_SONGS)) { for (final Object item : descriptionElements) { final JsonObject browseEndpoint = ((JsonObject) item) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java index 6996111ff..fb9774b98 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java @@ -37,6 +37,7 @@ public class StreamInfoItem extends InfoItem { private String uploaderName; private String shortDescription; private String textualUploadDate; + private String playlistId; @Nullable private DateWrapper uploadDate; private long viewCount = -1; @@ -118,6 +119,14 @@ public class StreamInfoItem extends InfoItem { this.textualUploadDate = textualUploadDate; } + public String getPlaylistId() { + return playlistId; + } + + public void setPlaylistId(final String playlistId) { + this.playlistId = playlistId; + } + @Nullable public DateWrapper getUploadDate() { return uploadDate; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java index c59b0aab3..b71ce6a1c 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java @@ -147,4 +147,14 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor { default boolean isShortFormContent() throws ParsingException { return false; } + + /** + * Gets the playlist id of the stream item. + * + * @return the playlist id of the stream item. + * @throws ParsingException if there is an error in the extraction + */ + default String getPlaylistId() throws ParsingException { + return ""; + } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java index 19cd2baa8..bcf25f0d2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java @@ -103,6 +103,11 @@ public class StreamInfoItemsCollector } catch (final Exception e) { addError(e); } + try { + resultItem.setPlaylistId(extractor.getPlaylistId()); + } catch (final Exception e) { + addError(e); + } return resultItem; } From b0d7dea83d5617e187bf71172d84bb9bbde5b3a5 Mon Sep 17 00:00:00 2001 From: wispl Date: Wed, 27 Aug 2025 11:59:58 -0400 Subject: [PATCH 3/3] fixup: formatting --- .../newpipe/extractor/stream/StreamInfoItemExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java index b71ce6a1c..6fb6f66be 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java @@ -155,6 +155,6 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor { * @throws ParsingException if there is an error in the extraction */ default String getPlaylistId() throws ParsingException { - return ""; + return ""; } }