[YouTube] Update NewPipeExtractor and adapt to removals

This commit is contained in:
AudricV
2026-08-30 18:22:57 +02:00
committed by Tobi
parent 5779af87f8
commit b4003d641e
3 changed files with 3 additions and 23 deletions
@@ -12,14 +12,9 @@ import static com.google.android.exoplayer2.upstream.DefaultHttpDataSource.DEFAU
import static com.google.android.exoplayer2.upstream.HttpUtil.buildRangeRequestHeader;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.Util.castNonNull;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getAndroidUserAgent;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getIosUserAgent;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getVisionOsUserAgent;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isAndroidStreamingUrl;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isIosStreamingUrl;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isVisionOsStreamingUrl;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isWebStreamingUrl;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isWebEmbeddedPlayerStreamingUrl;
import static java.lang.Math.min;
import android.net.Uri;
@@ -661,8 +656,7 @@ public final class YoutubeHttpDataSource extends BaseDataSource implements HttpD
}
}
if (isWebStreamingUrl(requestUrl)
|| isWebEmbeddedPlayerStreamingUrl(requestUrl)) {
if (isWebStreamingUrl(requestUrl)) {
httpURLConnection.setRequestProperty(HttpHeaders.ORIGIN, YOUTUBE_BASE_URL);
httpURLConnection.setRequestProperty(HttpHeaders.REFERER, YOUTUBE_BASE_URL);
httpURLConnection.setRequestProperty(HttpHeaders.SEC_FETCH_DEST, "empty");
@@ -672,15 +666,7 @@ public final class YoutubeHttpDataSource extends BaseDataSource implements HttpD
httpURLConnection.setRequestProperty(HttpHeaders.TE, "trailers");
if (isAndroidStreamingUrl(requestUrl)) {
// Improvement which may be done: find the content country used to request YouTube
// contents to add it in the user agent instead of using the default
httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT,
getAndroidUserAgent(null));
} else if (isIosStreamingUrl(requestUrl)) {
httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT,
getIosUserAgent(null));
} else if (isVisionOsStreamingUrl(requestUrl)) {
if (isVisionOsStreamingUrl(requestUrl)) {
httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT,
getVisionOsUserAgent(null));
} else {
@@ -123,10 +123,4 @@ object PoTokenProviderImpl : PoTokenProvider {
return PoTokenResult(visitorData, playerPot, streamingPot)
}
override fun getWebEmbedClientPoToken(videoId: String): PoTokenResult? = null
override fun getAndroidClientPoToken(videoId: String): PoTokenResult? = null
override fun getIosClientPoToken(videoId: String): PoTokenResult? = null
}