From 99f3f29c649bf7693c05bbce2bb49bd53e05f050 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 21 Dec 2024 18:49:56 +0400 Subject: [PATCH] fix(YouTube - Spoof video stream): Remove UI client type setting. Allow setting default audio language. (#4184) --- .../shared/settings/BaseSettings.java | 3 -- .../extension/shared/spoof/ClientType.java | 37 ++++++++++++------- .../shared/spoof/SpoofVideoStreamsPatch.java | 4 +- .../spoof/requests/StreamingDataRequest.java | 19 +--------- .../misc/spoof/SpoofVideoStreamsPatch.kt | 6 +-- .../resources/addresources/values/arrays.xml | 12 ------ .../resources/addresources/values/strings.xml | 4 +- 7 files changed, 30 insertions(+), 55 deletions(-) diff --git a/extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/BaseSettings.java b/extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/BaseSettings.java index e8f9c83517..4c0e79f21b 100644 --- a/extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/BaseSettings.java +++ b/extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/BaseSettings.java @@ -5,7 +5,6 @@ import static app.revanced.extension.shared.settings.Setting.parent; import app.revanced.extension.shared.spoof.AudioStreamLanguage; -import app.revanced.extension.shared.spoof.ClientType; /** * Settings shared across multiple apps. @@ -22,6 +21,4 @@ public class BaseSettings { 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 SPOOF_VIDEO_STREAMS_LANGUAGE = new EnumSetting<>("revanced_spoof_video_streams_language", AudioStreamLanguage.DEFAULT, parent(SPOOF_VIDEO_STREAMS)); - public static final EnumSetting SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_VR, true, parent(SPOOF_VIDEO_STREAMS)); - } 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 af274deb77..8df70412c9 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 @@ -6,33 +6,43 @@ public enum ClientType { // https://dumps.tadiphone.dev/dumps/oculus/eureka - ANDROID_VR( + ANDROID_VR_NO_AUTH( // Must be first so a default audio language can be set. 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 - ), + false), + // Fall over to authenticated ('hl' is ignored and audio is same as language set in users Google account). + ANDROID_VR( + ANDROID_VR_NO_AUTH.id, + ANDROID_VR_NO_AUTH.clientName, + ANDROID_VR_NO_AUTH.deviceModel, + ANDROID_VR_NO_AUTH.osVersion, + ANDROID_VR_NO_AUTH.userAgent, + ANDROID_VR_NO_AUTH.androidSdkVersion, + ANDROID_VR_NO_AUTH.clientVersion, + true), ANDROID_UNPLUGGED( 29, + "ANDROID_UNPLUGGED", "Google TV Streamer", "14", "com.google.android.apps.youtube.unplugged/8.49.0 (Linux; U; Android 14; GB) gzip", "34", "8.49.0", - true - ), + true), // Requires login. ANDROID_CREATOR( 14, - "Android", - "11", - "com.google.android.apps.youtube.creator/24.45.100 (Linux; U; Android 11) gzip", - "30", - "24.45.100", - true -); + "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. /** * YouTube @@ -75,6 +85,7 @@ public enum ClientType { public final boolean canLogin; ClientType(int id, + String clientName, String deviceModel, String osVersion, String userAgent, @@ -82,7 +93,7 @@ public enum ClientType { String clientVersion, boolean canLogin) { this.id = id; - this.clientName = name(); + this.clientName = clientName; this.deviceModel = deviceModel; this.osVersion = osVersion; this.userAgent = userAgent; diff --git a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java index dd13c9421d..e547baef6e 100644 --- a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java +++ b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java @@ -10,7 +10,6 @@ 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; @@ -35,8 +34,7 @@ public static final class NotSpoofingAndroidAvailability implements Setting.Avai @Override public boolean isAvailable() { if (SpoofVideoStreamsPatch.isPatchIncluded()) { - EnumSetting setting = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE; - return !setting.isAvailable() || setting.get().androidSdkVersion == null; + return !BaseSettings.SPOOF_VIDEO_STREAMS.get(); } return true; diff --git a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/requests/StreamingDataRequest.java b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/requests/StreamingDataRequest.java index 9c1ae74216..9020457e16 100644 --- a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/requests/StreamingDataRequest.java +++ b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/requests/StreamingDataRequest.java @@ -35,7 +35,7 @@ */ public class StreamingDataRequest { - private static final ClientType[] CLIENT_ORDER_TO_USE; + private static final ClientType[] CLIENT_ORDER_TO_USE = ClientType.values(); private static final String AUTHORIZATION_HEADER = "Authorization"; private static final String[] REQUEST_HEADER_KEYS = { AUTHORIZATION_HEADER, // Available only to logged-in users. @@ -67,21 +67,6 @@ protected boolean removeEldestEntry(Entry eldest) { } }); - static { - ClientType[] allClientTypes = ClientType.values(); - ClientType preferredClient = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get(); - - CLIENT_ORDER_TO_USE = new ClientType[allClientTypes.length]; - CLIENT_ORDER_TO_USE[0] = preferredClient; - - int i = 1; - for (ClientType c : allClientTypes) { - if (c != preferredClient) { - CLIENT_ORDER_TO_USE[i++] = c; - } - } - } - private final String videoId; private final Future future; @@ -178,7 +163,7 @@ private static ByteBuffer fetch(String videoId, Map playerHeader // gzip encoding doesn't response with content length (-1), // but empty response body does. if (connection.getContentLength() == 0) { - Logger.printDebug(() -> "Received empty response for video: " + videoId); + Logger.printDebug(() -> "Received empty response for client: " + clientType); } else { try (InputStream inputStream = new BufferedInputStream(connection.getInputStream()); ByteArrayOutputStream baos = new ByteArrayOutputStream()) { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/spoof/SpoofVideoStreamsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/spoof/SpoofVideoStreamsPatch.kt index 674854a4c5..d7cf7e18e1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/spoof/SpoofVideoStreamsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/spoof/SpoofVideoStreamsPatch.kt @@ -36,15 +36,11 @@ val spoofVideoStreamsPatch = spoofVideoStreamsPatch({ sorting = PreferenceScreenPreference.Sorting.UNSORTED, preferences = setOf( SwitchPreference("revanced_spoof_video_streams"), - ListPreference( - "revanced_spoof_video_streams_client_type", - summaryKey = null, - ), ListPreference( "revanced_spoof_video_streams_language", summaryKey = null ), - NonInteractivePreference("revanced_spoof_video_streams_about_android") + NonInteractivePreference("revanced_spoof_video_streams_about") ), ), ) diff --git a/patches/src/main/resources/addresources/values/arrays.xml b/patches/src/main/resources/addresources/values/arrays.xml index e3b93e71d6..e9826de73c 100644 --- a/patches/src/main/resources/addresources/values/arrays.xml +++ b/patches/src/main/resources/addresources/values/arrays.xml @@ -1,18 +1,6 @@ - - - Android VR - Android TV - Android Creator - - - - ANDROID_VR - ANDROID_UNPLUGGED - ANDROID_CREATOR - @string/revanced_spoof_video_streams_language_DEFAULT @string/revanced_spoof_video_streams_language_AR diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml index 2d994070bb..412d7dbb79 100644 --- a/patches/src/main/resources/addresources/values/strings.xml +++ b/patches/src/main/resources/addresources/values/strings.xml @@ -1297,8 +1297,8 @@ Enabling this can unlock higher video qualities" Video playback may not work" Turning off this setting may cause video playback issues. Default client - Android spoofing side effects - "• Kids videos may not play + Spoofing side effects + "• Kids videos may not play • Audio track menu is missing • Stable volume is not available • Force original audio is not available"