mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-25 19:55:57 +01:00
fix(YouTube - Spoof video streams): Use Android VR authentication if using default audio language (#4191)
This commit is contained in:
parent
f7d5701ad1
commit
98773cc7d4
@ -33,15 +33,6 @@ public enum ClientType {
|
|||||||
"com.google.android.apps.youtube.unplugged/8.49.0 (Linux; U; Android 14; GB) gzip",
|
"com.google.android.apps.youtube.unplugged/8.49.0 (Linux; U; Android 14; GB) gzip",
|
||||||
"34",
|
"34",
|
||||||
"8.49.0",
|
"8.49.0",
|
||||||
true), // Requires login.
|
|
||||||
ANDROID_CREATOR(
|
|
||||||
14,
|
|
||||||
"ANDROID_CREATOR",
|
|
||||||
"Android",
|
|
||||||
"11",
|
|
||||||
"com.google.android.apps.youtube.creator/24.45.100 (Linux; U; Android 11) gzip",
|
|
||||||
"30",
|
|
||||||
"24.45.100",
|
|
||||||
true); // Requires login.
|
true); // Requires login.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,7 @@ import java.util.concurrent.TimeoutException;
|
|||||||
import app.revanced.extension.shared.Logger;
|
import app.revanced.extension.shared.Logger;
|
||||||
import app.revanced.extension.shared.Utils;
|
import app.revanced.extension.shared.Utils;
|
||||||
import app.revanced.extension.shared.settings.BaseSettings;
|
import app.revanced.extension.shared.settings.BaseSettings;
|
||||||
|
import app.revanced.extension.shared.spoof.AudioStreamLanguage;
|
||||||
import app.revanced.extension.shared.spoof.ClientType;
|
import app.revanced.extension.shared.spoof.ClientType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,20 +37,25 @@ import app.revanced.extension.shared.spoof.ClientType;
|
|||||||
public class StreamingDataRequest {
|
public class StreamingDataRequest {
|
||||||
|
|
||||||
private static final ClientType[] CLIENT_ORDER_TO_USE = ClientType.values();
|
private static final ClientType[] CLIENT_ORDER_TO_USE = ClientType.values();
|
||||||
|
|
||||||
private static final String AUTHORIZATION_HEADER = "Authorization";
|
private static final String AUTHORIZATION_HEADER = "Authorization";
|
||||||
|
|
||||||
private static final String[] REQUEST_HEADER_KEYS = {
|
private static final String[] REQUEST_HEADER_KEYS = {
|
||||||
AUTHORIZATION_HEADER, // Available only to logged-in users.
|
AUTHORIZATION_HEADER, // Available only to logged-in users.
|
||||||
"X-GOOG-API-FORMAT-VERSION",
|
"X-GOOG-API-FORMAT-VERSION",
|
||||||
"X-Goog-Visitor-Id"
|
"X-Goog-Visitor-Id"
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TCP connection and HTTP read timeout.
|
* TCP connection and HTTP read timeout.
|
||||||
*/
|
*/
|
||||||
private static final int HTTP_TIMEOUT_MILLISECONDS = 10 * 1000;
|
private static final int HTTP_TIMEOUT_MILLISECONDS = 10 * 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any arbitrarily large value, but must be at least twice {@link #HTTP_TIMEOUT_MILLISECONDS}
|
* Any arbitrarily large value, but must be at least twice {@link #HTTP_TIMEOUT_MILLISECONDS}
|
||||||
*/
|
*/
|
||||||
private static final int MAX_MILLISECONDS_TO_WAIT_FOR_FETCH = 20 * 1000;
|
private static final int MAX_MILLISECONDS_TO_WAIT_FOR_FETCH = 20 * 1000;
|
||||||
|
|
||||||
private static final Map<String, StreamingDataRequest> cache = Collections.synchronizedMap(
|
private static final Map<String, StreamingDataRequest> cache = Collections.synchronizedMap(
|
||||||
new LinkedHashMap<>(100) {
|
new LinkedHashMap<>(100) {
|
||||||
/**
|
/**
|
||||||
@ -68,6 +74,7 @@ public class StreamingDataRequest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
private final String videoId;
|
private final String videoId;
|
||||||
|
|
||||||
private final Future<ByteBuffer> future;
|
private final Future<ByteBuffer> future;
|
||||||
|
|
||||||
private StreamingDataRequest(String videoId, Map<String, String> playerHeaders) {
|
private StreamingDataRequest(String videoId, Map<String, String> playerHeaders) {
|
||||||
@ -157,13 +164,21 @@ public class StreamingDataRequest {
|
|||||||
// Show an error if the last client type fails, or if the debug is enabled then show for all attempts.
|
// Show an error if the last client type fails, or if the debug is enabled then show for all attempts.
|
||||||
final boolean showErrorToast = (++i == CLIENT_ORDER_TO_USE.length) || debugEnabled;
|
final boolean showErrorToast = (++i == CLIENT_ORDER_TO_USE.length) || debugEnabled;
|
||||||
|
|
||||||
|
if (clientType == ClientType.ANDROID_VR_NO_AUTH
|
||||||
|
&& BaseSettings.SPOOF_VIDEO_STREAMS_LANGUAGE.get() == AudioStreamLanguage.DEFAULT) {
|
||||||
|
// Only use no auth Android VR if a non default audio language is selected.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
HttpURLConnection connection = send(clientType, videoId, playerHeaders, showErrorToast);
|
HttpURLConnection connection = send(clientType, videoId, playerHeaders, showErrorToast);
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
try {
|
try {
|
||||||
// gzip encoding doesn't response with content length (-1),
|
// gzip encoding doesn't response with content length (-1),
|
||||||
// but empty response body does.
|
// but empty response body does.
|
||||||
if (connection.getContentLength() == 0) {
|
if (connection.getContentLength() == 0) {
|
||||||
Logger.printDebug(() -> "Received empty response for client: " + clientType);
|
if (BaseSettings.DEBUG.get()) {
|
||||||
|
Logger.printException(() -> "Ignoring empty client response: " + clientType);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
try (InputStream inputStream = new BufferedInputStream(connection.getInputStream());
|
try (InputStream inputStream = new BufferedInputStream(connection.getInputStream());
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||||
|
@ -1298,12 +1298,11 @@ Video playback may not work"</string>
|
|||||||
<string name="revanced_spoof_video_streams_user_dialog_message">Turning off this setting may cause video playback issues.</string>
|
<string name="revanced_spoof_video_streams_user_dialog_message">Turning off this setting may cause video playback issues.</string>
|
||||||
<string name="revanced_spoof_video_streams_client_type_title">Default client</string>
|
<string name="revanced_spoof_video_streams_client_type_title">Default client</string>
|
||||||
<string name="revanced_spoof_video_streams_about_title">Spoofing side effects</string>
|
<string name="revanced_spoof_video_streams_about_title">Spoofing side effects</string>
|
||||||
<string name="revanced_spoof_video_streams_about_summary">"• Kids videos may not play
|
<string name="revanced_spoof_video_streams_about_summary">"• Audio track menu is missing
|
||||||
• Audio track menu is missing
|
|
||||||
• Stable volume is not available
|
• Stable volume is not available
|
||||||
• Force original audio is not available"</string>
|
• Force original audio is not available"</string>
|
||||||
<string name="revanced_spoof_video_streams_language_title">Default audio stream language</string>
|
<string name="revanced_spoof_video_streams_language_title">Default audio stream language</string>
|
||||||
<string name="revanced_spoof_video_streams_language_DEFAULT">App language</string>
|
<string name="revanced_spoof_video_streams_language_DEFAULT">Account language</string>
|
||||||
<string name="revanced_spoof_video_streams_language_AR">Arabic</string>
|
<string name="revanced_spoof_video_streams_language_AR">Arabic</string>
|
||||||
<string name="revanced_spoof_video_streams_language_AZ">Azerbaijani</string>
|
<string name="revanced_spoof_video_streams_language_AZ">Azerbaijani</string>
|
||||||
<string name="revanced_spoof_video_streams_language_BG">Bulgarian</string>
|
<string name="revanced_spoof_video_streams_language_BG">Bulgarian</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user