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 687bec828..0750904fe 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
@@ -66,7 +66,7 @@ public class YoutubeParsingHelper {
public static final String YOUTUBEI_V1_URL = "https://www.youtube.com/youtubei/v1/";
- private static final String HARDCODED_CLIENT_VERSION = "2.20210622.10.00";
+ private static final String HARDCODED_CLIENT_VERSION = "2.20210623.00.00";
private static final String HARDCODED_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
private static final String MOBILE_YOUTUBE_KEY = "AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w";
private static final String MOBILE_YOUTUBE_CLIENT_VERSION = "16.23.36";
@@ -324,8 +324,6 @@ public class YoutubeParsingHelper {
.value("clientVersion", HARDCODED_CLIENT_VERSION)
.end()
.object("user")
- // TO DO: provide a way to enable restricted mode with:
- // .value("enableSafetyMode", boolean)
.value("lockedSafetyMode", false)
.end()
.value("fetchLiveState", true)
@@ -353,7 +351,7 @@ public class YoutubeParsingHelper {
// Don't extract the client version and the innertube key if it has been already extracted
if (keyAndVersionExtracted) return;
// Don't provide a search term in order to have a smaller response
- final String url = "https://www.youtube.com/results?search_query=";
+ final String url = "https://www.youtube.com/results?search_query=&ucbcb=1";
final Map> headers = new HashMap<>();
addCookieHeader(headers);
final String html = getDownloader().get(url, headers).responseBody();
@@ -472,7 +470,7 @@ public class YoutubeParsingHelper {
* Only use in tests.
*
*/
- public static void setNumberGenerator(Random random) {
+ public static void setNumberGenerator(final Random random) {
numberGenerator = random;
}
@@ -749,6 +747,7 @@ public class YoutubeParsingHelper {
throws IOException, ExtractionException {
final Map> headers = new HashMap<>();
addClientInfoHeaders(headers);
+ headers.put("Content-Type", Collections.singletonList("application/json"));
final Response response = getDownloader().post(YOUTUBEI_V1_URL + endpoint + "?key="
+ getKey(), headers, body, localization);
@@ -814,6 +813,8 @@ public class YoutubeParsingHelper {
.value("clientVersion", getClientVersion())
.end()
.object("user")
+ // TO DO: provide a way to enable restricted mode with:
+ // .value("enableSafetyMode", boolean)
.value("lockedSafetyMode", false)
.end()
.end();
@@ -877,7 +878,7 @@ public class YoutubeParsingHelper {
* @see #CONSENT_COOKIE
* @param headers the headers which should be completed
*/
- public static void addCookieHeader(final Map> headers) {
+ public static void addCookieHeader(@Nonnull final Map> headers) {
if (headers.get("Cookie") == null) {
headers.put("Cookie", Arrays.asList(generateConsentCookie()));
} else {
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java
index 81e12c3f4..8dd037ce2 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java
@@ -85,7 +85,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
final String[] channelInfo = channel_path.split("/");
String id = "";
// If the url is an URL which is not a /channel URL, we need to use the
- // navigation/resolve_url endpoint of the internal API to get the channel id. Otherwise, we
+ // navigation/resolve_url endpoint of the youtubei API to get the channel id. Otherwise, we
// couldn't get information about the channel associated with this URL, if there is one.
if (!channelInfo[0].equals("channel")) {
final byte[] body = JsonWriter.string(prepareJsonBuilder(getExtractorLocalization(),
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java
index 959397c4f..84643784e 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java
@@ -189,7 +189,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
final Map> requestHeaders = new HashMap<>();
requestHeaders.put("User-Agent", singletonList(USER_AGENT));
- final Response response = downloader.get(getUrl(), requestHeaders, getExtractorLocalization());
+ final Response response = downloader.get(getUrl() + "&ucbcb=1", requestHeaders, getExtractorLocalization());
responseBody = YoutubeParsingHelper.unescapeDocument(response.responseBody());
ytClientVersion = findValue(responseBody, "INNERTUBE_CONTEXT_CLIENT_VERSION\":\"", "\"");
ytClientName = Parser.matchGroup1(YT_CLIENT_NAME_PATTERN, responseBody);
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 40db96ba8..357c6bd67 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
@@ -645,7 +645,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
public StreamType getStreamType() {
assertPageFetched();
- if (playerResponse.getObject("videoDetails").getBoolean("isLiveContent", false)) {
+ if (playerResponse.getObject("playabilityStatus").has("liveStreamability")
+ || playerResponse.getObject("videoDetails").getBoolean("isPostLiveDvr", false)) {
return StreamType.LIVE_STREAM;
}
return StreamType.VIDEO_STREAM;
diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeFeedExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeFeedExtractorTest.java
index 931e7526d..dd36aae94 100644
--- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeFeedExtractorTest.java
+++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeFeedExtractorTest.java
@@ -93,6 +93,5 @@ public class YoutubeFeedExtractorTest {
.getFeedExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ");
extractor.fetchPage();
}
-
}
}
\ No newline at end of file
diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java
index 5c2aaabc4..828a0e1e0 100644
--- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java
+++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java
@@ -3,6 +3,7 @@ package org.schabi.newpipe.extractor.services.youtube;
import com.grack.nanojson.JsonWriter;
import org.hamcrest.MatcherAssert;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -132,7 +133,7 @@ public class YoutubeMixPlaylistExtractorTest {
}
}
- @Ignore
+ @Ignore("Test broken, video was removed by the uploader")
public static class MixWithIndex {
private static final int INDEX = 13;
diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorControversialTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorControversialTest.java
index b0f40a779..58971db2d 100644
--- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorControversialTest.java
+++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorControversialTest.java
@@ -1,7 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.stream;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java
index 34b6dc3c1..8c095765d 100644
--- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java
+++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java
@@ -1,7 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.stream;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.NewPipe;