From 9333d7fcdc85e318f4368a6b932b8052d2a8a1ed Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Thu, 30 Jan 2025 20:17:31 +0100 Subject: [PATCH] [YouTube] Update DASH manifest creation clients' handling - Use POST requests with the same body as official clients do; - Update methods checking the client streaming URLs come from: - Replace TVHTML5_SIMPLY_EMBEDDED_PLAYER by TVHTML5; - Add WEB_EMBEDDED_PLAYER. --- .../youtube/YoutubeParsingHelper.java | 29 +++++++++++++------ .../YoutubeDashManifestCreatorsUtils.java | 13 +++++---- 2 files changed, 28 insertions(+), 14 deletions(-) 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 6b8742531..782ec6cb4 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 @@ -180,8 +180,10 @@ public final class YoutubeParsingHelper { "https://www.youtube.com/feeds/videos.xml?channel_id="; private static final String FEED_BASE_USER = "https://www.youtube.com/feeds/videos.xml?user="; private static final Pattern C_WEB_PATTERN = Pattern.compile("&c=WEB"); - private static final Pattern C_TVHTML5_SIMPLY_EMBEDDED_PLAYER_PATTERN = - Pattern.compile("&c=TVHTML5_SIMPLY_EMBEDDED_PLAYER"); + private static final Pattern C_WEB_EMBEDDED_PLAYER_PATTERN = + Pattern.compile("&c=WEB_EMBEDDED_PLAYER"); + private static final Pattern C_TVHTML5_PLAYER_PATTERN = + Pattern.compile("&c=TVHTML5"); private static final Pattern C_ANDROID_PATTERN = Pattern.compile("&c=ANDROID"); private static final Pattern C_IOS_PATTERN = Pattern.compile("&c=IOS"); @@ -1394,15 +1396,24 @@ public final class YoutubeParsingHelper { } /** - * Check if the streaming URL is a URL from the YouTube {@code TVHTML5_SIMPLY_EMBEDDED_PLAYER} - * client. + * Check if the streaming URL is from the YouTube {@code WEB_EMBEDDED_PLAYER} client. * - * @param url the streaming URL on which check if it's a {@code TVHTML5_SIMPLY_EMBEDDED_PLAYER} - * streaming URL. - * @return true if it's a {@code TVHTML5_SIMPLY_EMBEDDED_PLAYER} streaming URL, false otherwise + * @param url the streaming URL to be checked. + * @return true if it's a {@code WEB_EMBEDDED_PLAYER} streaming URL, false otherwise */ - public static boolean isTvHtml5SimplyEmbeddedPlayerStreamingUrl(@Nonnull final String url) { - return Parser.isMatch(C_TVHTML5_SIMPLY_EMBEDDED_PLAYER_PATTERN, url); + public static boolean isWebEmbeddedPlayerStreamingUrl(@Nonnull final String url) { + return Parser.isMatch(C_WEB_EMBEDDED_PLAYER_PATTERN, url); + } + + /** + * Check if the streaming URL is a URL from the YouTube {@code TVHTML5} client. + * + * @param url the streaming URL on which check if it's a {@code TVHTML5} + * streaming URL. + * @return true if it's a {@code TVHTML5} streaming URL, false otherwise + */ + public static boolean isTvHtml5StreamingUrl(@Nonnull final String url) { + return Parser.isMatch(C_TVHTML5_PLAYER_PATTERN, url); } /** diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreators/YoutubeDashManifestCreatorsUtils.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreators/YoutubeDashManifestCreatorsUtils.java index 0b4c41157..49dce80e4 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreators/YoutubeDashManifestCreatorsUtils.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreators/YoutubeDashManifestCreatorsUtils.java @@ -5,8 +5,9 @@ import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getIosUserAgent; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isAndroidStreamingUrl; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isIosStreamingUrl; -import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isTvHtml5SimplyEmbeddedPlayerStreamingUrl; +import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isTvHtml5StreamingUrl; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isWebStreamingUrl; +import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isWebEmbeddedPlayerStreamingUrl; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import org.schabi.newpipe.extractor.MediaFormat; @@ -582,8 +583,8 @@ public final class YoutubeDashManifestCreatorsUtils { * This method fetches, for OTF streams and for post-live-DVR streams: *