Skip to content

Commit 090debd

Browse files
committed
[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.
1 parent a26bcc5 commit 090debd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,16 @@ public void onFetchPage(@Nonnull final Downloader downloader)
823823
.getBytes(StandardCharsets.UTF_8);
824824
nextResponse = getJsonPostResponse(NEXT, body, localization);
825825

826-
if ((!isAgeRestricted && streamType == StreamType.VIDEO_STREAM)
826+
// streamType can only have LIVE_STREAM, POST_LIVE_STREAM and VIDEO_STREAM values (see
827+
// setStreamType()), so this block will be run only for POST_LIVE_STREAM and VIDEO_STREAM
828+
// values if fetching of the ANDROID client is not forced
829+
if ((!isAgeRestricted && streamType != StreamType.LIVE_STREAM)
827830
|| isAndroidClientFetchForced) {
828831
try {
829832
fetchAndroidMobileJsonPlayer(contentCountry, localization, videoId);
830833
} catch (final Exception ignored) {
834+
// Ignore exceptions related to ANDROID client fetch or parsing, as it is not
835+
// compulsory to play contents
831836
}
832837
}
833838

@@ -836,6 +841,8 @@ public void onFetchPage(@Nonnull final Downloader downloader)
836841
try {
837842
fetchIosMobileJsonPlayer(contentCountry, localization, videoId);
838843
} catch (final Exception ignored) {
844+
// Ignore exceptions related to IOS client fetch or parsing, as it is not
845+
// compulsory to play contents
839846
}
840847
}
841848
}

0 commit comments

Comments
 (0)