From 327a5730a883aa6725a629763a3df0cebda30d03 Mon Sep 17 00:00:00 2001 From: Xiang Rong Lin <41164160+XiangRongLin@users.noreply.github.com> Date: Sun, 2 Feb 2020 18:15:47 +0100 Subject: [PATCH] [Youtube] Add some comments to mix --- .../extractor/services/youtube/YoutubeParsingHelper.java | 6 ++++++ .../youtube/extractors/YoutubeMixPlaylistExtractor.java | 4 ++++ .../linkHandler/YoutubePlaylistLinkHandlerFactory.java | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java index 42420a1a7..258799692 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java @@ -192,6 +192,12 @@ public class YoutubeParsingHelper { } } + /** + * Checks if the given playlist id is a mix (auto-generated playlist) + * Ids from a mix start with "RD" + * @param playlistId + * @return Whether given id belongs to a mix + */ public static boolean isYoutubeMixId(String playlistId) { return playlistId.startsWith("RD"); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMixPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMixPlaylistExtractor.java index 64281931c..9da2e98fd 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMixPlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMixPlaylistExtractor.java @@ -18,6 +18,10 @@ import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingH import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; +/** + * A YoutubePlaylistExtractor for a mix (auto-generated playlist). + * It handles urls in the format of "youtube.com/watch?v=videoId&list=playlistId" + */ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor { private Document doc; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubePlaylistLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubePlaylistLinkHandlerFactory.java index 3d0ba78a5..ae66660c3 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubePlaylistLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubePlaylistLinkHandlerFactory.java @@ -71,6 +71,14 @@ public class YoutubePlaylistLinkHandlerFactory extends ListLinkHandlerFactory { return true; } + /** + * If it is a mix (auto-generated playlist) url, return a Linkhandler where the url is like + * youtube.com/watch?v=videoId&list=playlistId + *

Otherwise use super

+ * @param url + * @return + * @throws ParsingException + */ @Override public ListLinkHandler fromUrl(String url) throws ParsingException { try {