fix(YouTube - Spoof video streams): Change default spoofing to iOS, allow setting a default language with Android VR (#4171)

This commit is contained in:
LisoUseInAIKyrios
2024-12-21 00:38:11 +04:00
committed by GitHub
parent 66f8b0c25d
commit 171b4e7e40
11 changed files with 56 additions and 26 deletions

View File

@ -22,9 +22,9 @@ public class BaseSettings {
public static final IntegerSetting CHECK_ENVIRONMENT_WARNINGS_ISSUED = new IntegerSetting("revanced_check_environment_warnings_issued", 0, true, false);
public static final BooleanSetting SPOOF_VIDEO_STREAMS = new BooleanSetting("revanced_spoof_video_streams", TRUE, true, "revanced_spoof_video_streams_user_dialog_message");
public static final EnumSetting<AudioStreamLanguage> SPOOF_VIDEO_STREAMS_LANGUAGE = new EnumSetting<>("revanced_spoof_video_streams_language", AudioStreamLanguage.DEFAULT, new SpoofiOSAvailability());
public static final EnumSetting<AudioStreamLanguage> SPOOF_VIDEO_STREAMS_LANGUAGE = new EnumSetting<>("revanced_spoof_video_streams_language", AudioStreamLanguage.DEFAULT, parent(SPOOF_VIDEO_STREAMS));
public static final BooleanSetting SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC = new BooleanSetting("revanced_spoof_video_streams_ios_force_avc", FALSE, true,
"revanced_spoof_video_streams_ios_force_avc_user_dialog_message", new SpoofiOSAvailability());
public static final EnumSetting<ClientType> SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client", ClientType.ANDROID_VR, true, parent(SPOOF_VIDEO_STREAMS));
public static final EnumSetting<ClientType> SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.IOS, true, parent(SPOOF_VIDEO_STREAMS));
}

View File

@ -16,8 +16,8 @@ public enum ClientType {
"com.google.android.apps.youtube.vr.oculus/1.56.21 (Linux; U; Android 12; GB) gzip",
"32", // Android 12.1
"1.56.21",
true,
false),
true
),
// Specific for kids videos.
IOS(5,
"IOS",
@ -39,8 +39,7 @@ public enum ClientType {
// but 17.40 is the last version that supports iOS 13.
? "17.40.5"
: "19.47.7",
false,
true
false
);
private static boolean forceAVC() {
@ -87,11 +86,6 @@ public enum ClientType {
*/
public final boolean canLogin;
/**
* If a language code should be used.
*/
public final boolean useLanguageCode;
ClientType(int id,
String clientName,
String deviceModel,
@ -99,8 +93,7 @@ public enum ClientType {
String userAgent,
@Nullable String androidSdkVersion,
String clientVersion,
boolean canLogin,
boolean useLanguageCode) {
boolean canLogin) {
this.id = id;
this.clientName = clientName;
this.deviceModel = deviceModel;
@ -109,6 +102,5 @@ public enum ClientType {
this.androidSdkVersion = androidSdkVersion;
this.clientVersion = clientVersion;
this.canLogin = canLogin;
this.useLanguageCode = useLanguageCode;
}
}

View File

@ -10,6 +10,7 @@ import java.util.Map;
import app.revanced.extension.shared.Logger;
import app.revanced.extension.shared.Utils;
import app.revanced.extension.shared.settings.BaseSettings;
import app.revanced.extension.shared.settings.EnumSetting;
import app.revanced.extension.shared.settings.Setting;
import app.revanced.extension.shared.spoof.requests.StreamingDataRequest;
@ -26,6 +27,27 @@ public class SpoofVideoStreamsPatch {
private static final String UNREACHABLE_HOST_URI_STRING = "https://127.0.0.0";
private static final Uri UNREACHABLE_HOST_URI = Uri.parse(UNREACHABLE_HOST_URI_STRING);
/**
* @return If this patch was included during patching.
*/
private static boolean isPatchIncluded() {
return false; // Modified during patching.
}
public static final class NotSpoofingAndroidVrAvailability implements Setting.Availability {
@Override
public boolean isAvailable() {
if (SpoofVideoStreamsPatch.isPatchIncluded()) {
EnumSetting<ClientType> clientType = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE;
return clientType.isAvailable() && clientType.get() != ClientType.ANDROID_VR;
}
return true;
}
}
/**
* Injection point.
* Blocks /get_watch requests by returning an unreachable URI.

View File

@ -37,9 +37,7 @@ final class PlayerRoutes {
JSONObject context = new JSONObject();
JSONObject client = new JSONObject();
if (clientType.useLanguageCode) {
client.put("hl", BaseSettings.SPOOF_VIDEO_STREAMS_LANGUAGE.get().getIso639_1());
}
client.put("hl", BaseSettings.SPOOF_VIDEO_STREAMS_LANGUAGE.get().getIso639_1());
client.put("clientName", clientType.clientName);
client.put("clientVersion", clientType.clientVersion);
client.put("deviceModel", clientType.deviceModel);