Skip to content

Commit 2e92d71

Browse files
authored
Merge pull request #780 from TiA4f8R/yt-more-params-innertube-requests
[YouTube] Add more parameters to InnerTube requests, use the iOS client for livestreams and fix extraction of embeddable age-restricted videos and contents with a warning before playback
2 parents 5a18730 + b30e341 commit 2e92d71

File tree

263 files changed

+36858
-26271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+36858
-26271
lines changed

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

Lines changed: 422 additions & 200 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.extractor.services.youtube.extractors;
22

3+
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
34
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL;
45
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addClientInfoHeaders;
56
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl;
@@ -395,7 +396,8 @@ private Page getNextPageFrom(final JsonObject continuations,
395396
.done())
396397
.getBytes(UTF_8);
397398

398-
return new Page(YOUTUBEI_V1_URL + "browse?key=" + getKey(), null, channelIds, null, body);
399+
return new Page(YOUTUBEI_V1_URL + "browse?key=" + getKey()
400+
+ DISABLE_PRETTY_PRINT_PARAMETER, null, channelIds, null, body);
399401
}
400402

401403
/**

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.extractor.services.youtube.extractors;
22

3+
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
34
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL;
45
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addClientInfoHeaders;
56
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.extractCookieValue;
@@ -90,8 +91,8 @@ public void onFetchPage(@Nonnull final Downloader downloader)
9091
final Map<String, List<String>> headers = new HashMap<>();
9192
addClientInfoHeaders(headers);
9293

93-
final Response response = getDownloader().post(YOUTUBEI_V1_URL + "next?key=" + getKey(),
94-
headers, body, localization);
94+
final Response response = getDownloader().post(YOUTUBEI_V1_URL + "next?key=" + getKey()
95+
+ DISABLE_PRETTY_PRINT_PARAMETER, headers, body, localization);
9596

9697
initialData = JsonUtils.toJsonObject(getValidJsonResponseBody(response));
9798
playlistData = initialData.getObject("contents").getObject("twoColumnWatchNextResults")

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.extractor.services.youtube.extractors;
22

3+
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
34
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl;
45
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject;
56
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint;
@@ -60,7 +61,7 @@ public void onFetchPage(@Nonnull final Downloader downloader)
6061
final String[] youtubeMusicKeys = YoutubeParsingHelper.getYoutubeMusicKey();
6162

6263
final String url = "https://music.youtube.com/youtubei/v1/search?alt=json&key="
63-
+ youtubeMusicKeys[0];
64+
+ youtubeMusicKeys[0] + DISABLE_PRETTY_PRINT_PARAMETER;
6465

6566
final String params;
6667

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.extractor.services.youtube.extractors;
22

3+
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
34
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL;
45
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addClientInfoHeaders;
56
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.extractPlaylistTypeFromPlaylistUrl;
@@ -317,7 +318,8 @@ private Page getNextPageFrom(final JsonArray contents)
317318
.done())
318319
.getBytes(StandardCharsets.UTF_8);
319320

320-
return new Page(YOUTUBEI_V1_URL + "browse?key=" + getKey(), body);
321+
return new Page(YOUTUBEI_V1_URL + "browse?key=" + getKey()
322+
+ DISABLE_PRETTY_PRINT_PARAMETER, body);
321323
} else {
322324
return null;
323325
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.extractor.services.youtube.extractors;
22

3+
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
34
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL;
45
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonPostResponse;
56
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getKey;
@@ -239,7 +240,8 @@ private Page getNextPageFrom(final JsonObject continuationItemRenderer) throws I
239240
final String token = continuationItemRenderer.getObject("continuationEndpoint")
240241
.getObject("continuationCommand").getString("token");
241242

242-
final String url = YOUTUBEI_V1_URL + "search?key=" + getKey();
243+
final String url = YOUTUBEI_V1_URL + "search?key=" + getKey()
244+
+ DISABLE_PRETTY_PRINT_PARAMETER;
243245

244246
return new Page(url, token);
245247
}

0 commit comments

Comments
 (0)