From 090debd83b80b05e54d08abb2531453c5fc4e73c Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Mon, 20 Jun 2022 22:04:09 +0200 Subject: [PATCH] [YouTube] Fetch the ANDROID client for ended/post livestreams The ANDROID client was only fetched for video contents, where it can be useful on ended/post livestreams, if the n parameter of the WEB client cannot be decrypted, to avoid throttling issues (because the WEB client was only used before for ended/post livestreams). It also provides an exclusive 48kbps M4A audio format in the adaptiveFormats array of the JSON player response, like other mobile clients (which can be also extracted from the response of the DASH manifest URL returned into the WEB client player's response, but the DASH manifest is not used by the extractor). A note about non-fatality of fetching or parsing issues of the ANDROID and IOS clients has been added. --- .../youtube/extractors/YoutubeStreamExtractor.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index 3fdd69bf5..3e54741bc 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -823,11 +823,16 @@ public class YoutubeStreamExtractor extends StreamExtractor { .getBytes(StandardCharsets.UTF_8); nextResponse = getJsonPostResponse(NEXT, body, localization); - if ((!isAgeRestricted && streamType == StreamType.VIDEO_STREAM) + // streamType can only have LIVE_STREAM, POST_LIVE_STREAM and VIDEO_STREAM values (see + // setStreamType()), so this block will be run only for POST_LIVE_STREAM and VIDEO_STREAM + // values if fetching of the ANDROID client is not forced + if ((!isAgeRestricted && streamType != StreamType.LIVE_STREAM) || isAndroidClientFetchForced) { try { fetchAndroidMobileJsonPlayer(contentCountry, localization, videoId); } catch (final Exception ignored) { + // Ignore exceptions related to ANDROID client fetch or parsing, as it is not + // compulsory to play contents } } @@ -836,6 +841,8 @@ public class YoutubeStreamExtractor extends StreamExtractor { try { fetchIosMobileJsonPlayer(contentCountry, localization, videoId); } catch (final Exception ignored) { + // Ignore exceptions related to IOS client fetch or parsing, as it is not + // compulsory to play contents } } }