From 7eeffd3392c57555342173103d3a417c038d0970 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 17 Sep 2025 01:44:48 +0400 Subject: [PATCH] fix(YouTube Music - Spoof video streams): Remove iPadOS client --- .../patches/spoof/SpoofVideoStreamsPatch.java | 5 ++- .../extension/music/settings/Settings.java | 8 ++++ .../shared/settings/BaseSettings.java | 4 -- .../extension/shared/spoof/ClientType.java | 15 -------- .../shared/spoof/SpoofVideoStreamsPatch.java | 37 ++++++++++--------- .../shared/spoof/requests/PlayerRoutes.java | 6 +-- .../spoof/requests/StreamingDataRequest.java | 2 +- .../patches/spoof/SpoofVideoStreamsPatch.java | 7 ++-- .../extension/youtube/settings/Settings.java | 2 + ...oofStreamingDataSideEffectsPreference.java | 3 +- .../misc/spoof/SpoofVideoStreamsPatch.kt | 2 +- .../resources/addresources/values/arrays.xml | 16 +++++++- 12 files changed, 59 insertions(+), 48 deletions(-) diff --git a/extensions/music/src/main/java/app/revanced/extension/music/patches/spoof/SpoofVideoStreamsPatch.java b/extensions/music/src/main/java/app/revanced/extension/music/patches/spoof/SpoofVideoStreamsPatch.java index f6d248715..170d287be 100644 --- a/extensions/music/src/main/java/app/revanced/extension/music/patches/spoof/SpoofVideoStreamsPatch.java +++ b/extensions/music/src/main/java/app/revanced/extension/music/patches/spoof/SpoofVideoStreamsPatch.java @@ -1,5 +1,6 @@ package app.revanced.extension.music.patches.spoof; +import static app.revanced.extension.music.settings.Settings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE; import static app.revanced.extension.shared.spoof.ClientType.ANDROID_VR_1_43_32; import static app.revanced.extension.shared.spoof.ClientType.ANDROID_VR_1_61_48; import static app.revanced.extension.shared.spoof.ClientType.VISIONOS; @@ -22,6 +23,8 @@ public class SpoofVideoStreamsPatch { VISIONOS ); - StreamingDataRequest.setClientOrderToUse(availableClients, ANDROID_VR_1_43_32); + ClientType client = SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get(); + app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch.setPreferredClient(client); + StreamingDataRequest.setClientOrderToUse(availableClients, client); } } diff --git a/extensions/music/src/main/java/app/revanced/extension/music/settings/Settings.java b/extensions/music/src/main/java/app/revanced/extension/music/settings/Settings.java index 394cc7b3e..f793eef0f 100644 --- a/extensions/music/src/main/java/app/revanced/extension/music/settings/Settings.java +++ b/extensions/music/src/main/java/app/revanced/extension/music/settings/Settings.java @@ -3,8 +3,12 @@ package app.revanced.extension.music.settings; import static java.lang.Boolean.FALSE; import static java.lang.Boolean.TRUE; +import static app.revanced.extension.shared.settings.Setting.parent; + import app.revanced.extension.shared.settings.BaseSettings; import app.revanced.extension.shared.settings.BooleanSetting; +import app.revanced.extension.shared.settings.EnumSetting; +import app.revanced.extension.shared.spoof.ClientType; public class Settings extends BaseSettings { @@ -18,4 +22,8 @@ public class Settings extends BaseSettings { // Player public static final BooleanSetting PERMANENT_REPEAT = new BooleanSetting("revanced_music_play_permanent_repeat", FALSE, true); + + // Miscellaneous + public static final EnumSetting SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", + ClientType.ANDROID_VR_1_43_32, true, parent(SPOOF_VIDEO_STREAMS)); } 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 2cb08ff90..be4b58227 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,8 +5,6 @@ import static java.lang.Boolean.TRUE; import static app.revanced.extension.shared.settings.Setting.parent; import static app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch.AudioStreamLanguageOverrideAvailability; -import app.revanced.extension.shared.spoof.ClientType; - /** * Settings shared across multiple apps. *

@@ -30,6 +28,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", AppLanguage.DEFAULT, new AudioStreamLanguageOverrideAvailability()); public static final BooleanSetting SPOOF_STREAMING_DATA_STATS_FOR_NERDS = new BooleanSetting("revanced_spoof_streaming_data_stats_for_nerds", TRUE, parent(SPOOF_VIDEO_STREAMS)); - // Client type must be last spoof setting due to cyclic references. - public static final EnumSetting SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_VR_1_61_48, 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 2cbe83ad6..c8323039e 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 @@ -31,7 +31,6 @@ public enum ClientType { "132.0.6808.3", "1.61.48", false, - false, "Android VR 1.61" ), /** @@ -50,7 +49,6 @@ public enum ClientType { Objects.requireNonNull(ANDROID_VR_1_61_48.buildId), "107.0.5284.2", "1.43.32", - ANDROID_VR_1_61_48.requiresAuth, ANDROID_VR_1_61_48.useAuth, "Android VR 1.43" ), @@ -71,7 +69,6 @@ public enum ClientType { "132.0.6779.0", "23.47.101", true, - true, "Android Creator" ), /** @@ -86,7 +83,6 @@ public enum ClientType { "0.1", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15", false, - false, "visionOS" ), /** @@ -111,7 +107,6 @@ public enum ClientType { "19.22.3", "com.google.ios.youtube/19.22.3 (iPad7,6; U; CPU iPadOS 17_7_10 like Mac OS X; " + Locale.getDefault() + ")", false, - false, "iPadOS" ); @@ -180,12 +175,6 @@ public enum ClientType { */ public final String clientVersion; - /** - * If this client requires authentication and does not work - * if logged out or in incognito mode. - */ - public final boolean requiresAuth; - /** * If the client should use authentication if available. */ @@ -210,7 +199,6 @@ public enum ClientType { @NonNull String buildId, @NonNull String cronetVersion, String clientVersion, - boolean requiresAuth, boolean useAuth, String friendlyName) { this.id = id; @@ -224,7 +212,6 @@ public enum ClientType { this.buildId = buildId; this.cronetVersion = cronetVersion; this.clientVersion = clientVersion; - this.requiresAuth = requiresAuth; this.useAuth = useAuth; this.friendlyName = friendlyName; @@ -250,7 +237,6 @@ public enum ClientType { String osVersion, String clientVersion, String userAgent, - boolean requiresAuth, boolean useAuth, String friendlyName) { this.id = id; @@ -261,7 +247,6 @@ public enum ClientType { this.osVersion = osVersion; this.clientVersion = clientVersion; this.userAgent = userAgent; - this.requiresAuth = requiresAuth; this.useAuth = useAuth; this.friendlyName = friendlyName; this.packageName = null; 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 12265a73a..7baa9d076 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 @@ -7,6 +7,7 @@ import androidx.annotation.Nullable; import java.nio.ByteBuffer; import java.util.Map; +import java.util.Objects; import app.revanced.extension.shared.Logger; import app.revanced.extension.shared.Utils; @@ -17,14 +18,6 @@ import app.revanced.extension.shared.spoof.requests.StreamingDataRequest; @SuppressWarnings("unused") public class SpoofVideoStreamsPatch { - private static final boolean SPOOF_STREAMING_DATA = BaseSettings.SPOOF_VIDEO_STREAMS.get(); - - private static final boolean FIX_HLS_CURRENT_TIME = SPOOF_STREAMING_DATA - && BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ClientType.VISIONOS; - - @Nullable - private static volatile AppLanguage languageOverride; - /** * Domain used for internet connectivity verification. * It has an empty response body and is only used to check for a 204 response code. @@ -40,6 +33,13 @@ public class SpoofVideoStreamsPatch { private static final String INTERNET_CONNECTION_CHECK_URI_STRING = "https://www.google.com/gen_204"; private static final Uri INTERNET_CONNECTION_CHECK_URI = Uri.parse(INTERNET_CONNECTION_CHECK_URI_STRING); + private static final boolean SPOOF_STREAMING_DATA = BaseSettings.SPOOF_VIDEO_STREAMS.get(); + + @Nullable + private static volatile AppLanguage languageOverride; + + private static volatile ClientType preferredClient = ClientType.ANDROID_VR_1_61_48; + /** * @return If this patch was included during patching. */ @@ -47,10 +47,9 @@ public class SpoofVideoStreamsPatch { return false; // Modified during patching. } - public static boolean spoofingToClientWithNoMultiAudioStreams() { - return isPatchIncluded() - && BaseSettings.SPOOF_VIDEO_STREAMS.get() - && BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() != ClientType.IPADOS; + @Nullable + public static AppLanguage getLanguageOverride() { + return languageOverride; } /** @@ -61,9 +60,14 @@ public class SpoofVideoStreamsPatch { languageOverride = language; } - @Nullable - public static AppLanguage getLanguageOverride() { - return languageOverride; + public static void setPreferredClient(ClientType client) { + preferredClient = Objects.requireNonNull(client); + } + + public static boolean spoofingToClientWithNoMultiAudioStreams() { + return isPatchIncluded() + && SPOOF_STREAMING_DATA + && preferredClient != ClientType.IPADOS; } /** @@ -278,8 +282,7 @@ public class SpoofVideoStreamsPatch { public static final class AudioStreamLanguageOverrideAvailability implements Setting.Availability { @Override public boolean isAvailable() { - // Since all current clients are un-authenticated, this works for all spoof clients. - return BaseSettings.SPOOF_VIDEO_STREAMS.get(); + return BaseSettings.SPOOF_VIDEO_STREAMS.get() && !preferredClient.useAuth; } } } 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 82db445d7..ef5907b01 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 @@ -42,10 +42,10 @@ final class PlayerRoutes { JSONObject context = new JSONObject(); AppLanguage language = SpoofVideoStreamsPatch.getLanguageOverride(); - if (language == null || BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ANDROID_VR_1_43_32) { + if (language == null || clientType == ANDROID_VR_1_43_32) { // Force original audio has not overrode the language. - // Or if YT has fallen over to the very last client (VR 1.43), then always - // use the app language because forcing an audio stream of specific languages + // Or if YT has fallen over to the last unauthenticated client (VR 1.43), then + // always use the app language because forcing an audio stream of specific languages // can sometimes fail so it's better to try and load something rather than nothing. language = BaseSettings.SPOOF_VIDEO_STREAMS_LANGUAGE.get(); } 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 a9651e07a..5a4ebd1c3 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 @@ -177,7 +177,7 @@ public class StreamingDataRequest { } } - if (!authHeadersIncludes && clientType.requiresAuth) { + if (!authHeadersIncludes && clientType.useAuth) { Logger.printDebug(() -> "Skipping client since user is not logged in: " + clientType + " videoId: " + videoId); return null; diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/spoof/SpoofVideoStreamsPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/spoof/SpoofVideoStreamsPatch.java index 10562d489..45e49919c 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/spoof/SpoofVideoStreamsPatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/spoof/SpoofVideoStreamsPatch.java @@ -8,9 +8,9 @@ import static app.revanced.extension.shared.spoof.ClientType.VISIONOS; import java.util.List; -import app.revanced.extension.shared.settings.BaseSettings; import app.revanced.extension.shared.spoof.ClientType; import app.revanced.extension.shared.spoof.requests.StreamingDataRequest; +import app.revanced.extension.youtube.settings.Settings; @SuppressWarnings("unused") public class SpoofVideoStreamsPatch { @@ -27,7 +27,8 @@ public class SpoofVideoStreamsPatch { IPADOS ); - StreamingDataRequest.setClientOrderToUse(availableClients, - BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get()); + ClientType client = Settings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get(); + app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch.setPreferredClient(client); + StreamingDataRequest.setClientOrderToUse(availableClients, client); } } \ No newline at end of file diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java index d40879a3c..8f6b51920 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -41,6 +41,7 @@ import app.revanced.extension.shared.settings.LongSetting; import app.revanced.extension.shared.settings.Setting; import app.revanced.extension.shared.settings.StringSetting; import app.revanced.extension.shared.settings.preference.SharedPrefCategory; +import app.revanced.extension.shared.spoof.ClientType; import app.revanced.extension.youtube.patches.AlternativeThumbnailsPatch.DeArrowAvailability; import app.revanced.extension.youtube.patches.AlternativeThumbnailsPatch.StillImagesAvailability; import app.revanced.extension.youtube.patches.AlternativeThumbnailsPatch.ThumbnailOption; @@ -356,6 +357,7 @@ public class Settings extends BaseSettings { public static final BooleanSetting REMOVE_TRACKING_QUERY_PARAMETER = new BooleanSetting("revanced_remove_tracking_query_parameter", TRUE); public static final BooleanSetting SPOOF_DEVICE_DIMENSIONS = new BooleanSetting("revanced_spoof_device_dimensions", FALSE, true, "revanced_spoof_device_dimensions_user_dialog_message"); + public static final EnumSetting SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_VR_1_61_48, true, parent(SPOOF_VIDEO_STREAMS)); public static final BooleanSetting DEBUG_PROTOBUFFER = new BooleanSetting("revanced_debug_protobuffer", FALSE, false, "revanced_debug_protobuffer_user_dialog_message", parent(BaseSettings.DEBUG)); diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/preference/SpoofStreamingDataSideEffectsPreference.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/preference/SpoofStreamingDataSideEffectsPreference.java index 04f366a2f..d20881762 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/preference/SpoofStreamingDataSideEffectsPreference.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/preference/SpoofStreamingDataSideEffectsPreference.java @@ -15,6 +15,7 @@ import app.revanced.extension.shared.Utils; import app.revanced.extension.shared.settings.BaseSettings; import app.revanced.extension.shared.settings.Setting; import app.revanced.extension.shared.spoof.ClientType; +import app.revanced.extension.youtube.settings.Settings; @SuppressWarnings({"deprecation", "unused"}) public class SpoofStreamingDataSideEffectsPreference extends Preference { @@ -69,7 +70,7 @@ public class SpoofStreamingDataSideEffectsPreference extends Preference { } private void updateUI() { - ClientType clientType = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get(); + ClientType clientType = Settings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get(); if (currentClientType == clientType) { return; } diff --git a/patches/src/main/kotlin/app/revanced/patches/music/misc/spoof/SpoofVideoStreamsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/misc/spoof/SpoofVideoStreamsPatch.kt index 7d1a4c648..0452bc3cf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/misc/spoof/SpoofVideoStreamsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/misc/spoof/SpoofVideoStreamsPatch.kt @@ -38,7 +38,7 @@ val spoofVideoStreamsPatch = spoofVideoStreamsPatch( ) }, executeBlock = { - addResources("shared", "misc.spoof.spoofVideoStreamsPatch") + addResources("music", "misc.fix.playback.spoofVideoStreamsPatch") PreferenceScreen.MISC.addPreferences( PreferenceScreenPreference( diff --git a/patches/src/main/resources/addresources/values/arrays.xml b/patches/src/main/resources/addresources/values/arrays.xml index 1c174cad0..9359dc1c3 100644 --- a/patches/src/main/resources/addresources/values/arrays.xml +++ b/patches/src/main/resources/addresources/values/arrays.xml @@ -121,6 +121,20 @@ ZH + + + + + Android VR + visionOS + + + ANDROID_VR_1_43_32 + VISIONOS + + + + Android VR @@ -133,8 +147,6 @@ IPADOS - - @string/revanced_swipe_overlay_style_entry_1