Skip to content

Commit 4644e17

Browse files
AudricVStypox
authored andcommitted
[YouTube] Add signatureTimestamp argument to TVHTML5 client requests
This argument, which has been forgot, is required to get valid streaming URLs with this client.
1 parent 61f6785 commit 4644e17

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ public static JsonObject getTvHtml5PlayerResponse(
119119
@Nonnull final Localization localization,
120120
@Nonnull final ContentCountry contentCountry,
121121
@Nonnull final String videoId,
122-
@Nonnull final String cpn) throws IOException, ExtractionException {
122+
@Nonnull final String cpn,
123+
final int signatureTimestamp) throws IOException, ExtractionException {
123124
final InnertubeClientRequestInfo innertubeClientRequestInfo =
124125
new InnertubeClientRequestInfo(
125126
new InnertubeClientRequestInfo.ClientInfo(
@@ -154,6 +155,8 @@ public static JsonObject getTvHtml5PlayerResponse(
154155

155156
addVideoIdCpnAndOkChecks(builder, videoId, cpn);
156157

158+
addPlaybackContext(builder, BASE_YT_DESKTOP_WATCH_URL + videoId, signatureTimestamp);
159+
157160
final byte[] body = JsonWriter.string(builder.done())
158161
.getBytes(StandardCharsets.UTF_8);
159162

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,8 @@ private void fetchHtml5Client(@Nonnull final Localization localization,
941941

942942
final JsonObject tvHtml5PlayerResponse =
943943
YoutubeStreamHelper.getTvHtml5PlayerResponse(
944-
localization, contentCountry, videoId, html5Cpn);
944+
localization, contentCountry, videoId, html5Cpn,
945+
YoutubeJavaScriptPlayerManager.getSignatureTimestamp(videoId));
945946

946947
if (isPlayerResponseNotValid(tvHtml5PlayerResponse, videoId)) {
947948
throw new ExtractionException("TVHTML5 player response is not valid");

0 commit comments

Comments
 (0)