From 839a4045f1bb1759d89047834e0b7695781e82a3 Mon Sep 17 00:00:00 2001
From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
Date: Wed, 11 Dec 2024 00:42:56 +0400
Subject: [PATCH] fix(YouTube - Spoof video streams): Resolve playback of age
restricted videos (#4096)
---
.../extension/shared/spoof/ClientType.java | 38 ++++++++++++++++---
.../shared/spoof/requests/PlayerRoutes.java | 6 ++-
.../resources/addresources/values/strings.xml | 4 +-
3 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/ClientType.java b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/ClientType.java
index ddf170f78c..f51779a15a 100644
--- a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/ClientType.java
+++ b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/ClientType.java
@@ -10,15 +10,17 @@ public enum ClientType {
// Specific purpose for age restricted, or private videos, because the iOS client is not logged in.
// https://dumps.tadiphone.dev/dumps/oculus/eureka
ANDROID_VR(28,
+ "ANDROID_VR",
"Quest 3",
"12",
"com.google.android.apps.youtube.vr.oculus/1.56.21 (Linux; U; Android 12; GB) gzip",
"32", // Android 12.1
"1.56.21",
- true
- ),
+ true,
+ true),
// Specific for kids videos.
IOS(5,
+ "IOS",
forceAVC()
? "iPhone12,5" // 11 Pro Max (last device with iOS 13)
: "iPhone16,2", // 15 Pro Max
@@ -37,8 +39,22 @@ public enum ClientType {
// but 17.40 is the last version that supports iOS 13.
? "17.40.5"
: "19.47.7",
- false
- );
+ false,
+ true),
+ /**
+ * Android VR with no language code.
+ * Used for age restricted videos and YouTube Music to disable stable volume.
+ */
+ ANDROID_VR_NO_HL(
+ ANDROID_VR.id,
+ ANDROID_VR.clientName,
+ ANDROID_VR.deviceModel,
+ ANDROID_VR.osVersion,
+ ANDROID_VR.userAgent,
+ ANDROID_VR.androidSdkVersion,
+ ANDROID_VR.clientVersion,
+ ANDROID_VR.canLogin,
+ false);
private static boolean forceAVC() {
return BaseSettings.SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC.get();
@@ -50,6 +66,8 @@ private static boolean forceAVC() {
*/
public final int id;
+ public final String clientName;
+
/**
* Device model, equivalent to {@link Build#MODEL} (System property: ro.product.model)
*/
@@ -82,20 +100,28 @@ private static boolean forceAVC() {
*/
public final boolean canLogin;
+ /**
+ * If a language code should be used.
+ */
+ public final boolean useLanguageCode;
+
ClientType(int id,
+ String clientName,
String deviceModel,
String osVersion,
String userAgent,
@Nullable String androidSdkVersion,
String clientVersion,
- boolean canLogin
- ) {
+ boolean canLogin,
+ boolean useLanguageCode) {
this.id = id;
+ this.clientName = clientName;
this.deviceModel = deviceModel;
this.osVersion = osVersion;
this.userAgent = userAgent;
this.androidSdkVersion = androidSdkVersion;
this.clientVersion = clientVersion;
this.canLogin = canLogin;
+ this.useLanguageCode = useLanguageCode;
}
}
diff --git a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/requests/PlayerRoutes.java b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/requests/PlayerRoutes.java
index 6f6a6e7c52..ca1a0eb897 100644
--- a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/requests/PlayerRoutes.java
+++ b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/requests/PlayerRoutes.java
@@ -35,8 +35,10 @@ static String createInnertubeBody(ClientType clientType) {
JSONObject context = new JSONObject();
JSONObject client = new JSONObject();
- client.put("hl", BaseSettings.SPOOF_VIDEO_STREAMS_LANGUAGE.get().getIso639_1());
- client.put("clientName", clientType.name());
+ if (clientType.useLanguageCode) {
+ 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);
client.put("osVersion", clientType.osVersion);
diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml
index b8cb89820a..83f9da6bd6 100644
--- a/patches/src/main/resources/addresources/values/strings.xml
+++ b/patches/src/main/resources/addresources/values/strings.xml
@@ -1229,9 +1229,9 @@ This is because Crowdin requires temporarily flattening this file and removing t
Video codec is determined automatically
Enabling this might improve battery life and fix playback stuttering.\n\nAVC has a maximum resolution of 1080p, Opus audio codec is not available, and video playback will use more internet data than VP9 or AV1.
iOS spoofing side effects
- • Private kids videos may not play\n• Age restricted videos may not play\n• Livestreams start from the beginning\n• Videos end 1 second early
+ • Private kids videos may not play\n• Livestreams start from the beginning\n• Videos end 1 second early
Android VR spoofing side effects
- • Kids videos may not play\n• Age restricted videos may not play\n• Livestreams start from the beginning\n• Videos end 1 second early
+ • Kids videos may not play\n• Livestreams start from the beginning\n• Videos end 1 second early
Default audio stream language
App language
Arabic