mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2026-09-09 02:39:12 +00:00
[YouTube] Support new client in YoutubeHttpDataSource
This commit is contained in:
@@ -14,8 +14,10 @@ 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;
|
||||
@@ -670,16 +672,17 @@ public final class YoutubeHttpDataSource extends BaseDataSource implements HttpD
|
||||
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.TE, "trailers");
|
||||
|
||||
final boolean isAndroidStreamingUrl = isAndroidStreamingUrl(requestUrl);
|
||||
final boolean isIosStreamingUrl = isIosStreamingUrl(requestUrl);
|
||||
if (isAndroidStreamingUrl) {
|
||||
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) {
|
||||
} else if (isIosStreamingUrl(requestUrl)) {
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT,
|
||||
getIosUserAgent(null));
|
||||
} else if (isVisionOsStreamingUrl(requestUrl)) {
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT,
|
||||
getVisionOsUserAgent(null));
|
||||
} else {
|
||||
// non-mobile user agent
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT, DownloaderImpl.USER_AGENT);
|
||||
|
||||
Reference in New Issue
Block a user