From dbccff0fdcc8379952701dfe0a7cc0338cf850d3 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 14 Dec 2024 05:53:00 +0100 Subject: [PATCH] fix(YouTube Music - Spoof video streams): Use `IOS_MUSIC` client to fix playback issues --- .../extension/shared/spoof/ClientType.java | 33 +++++++------------ .../shared/spoof/SpoofVideoStreamsPatch.java | 8 ++--- .../misc/spoof/SpoofVideoStreamsPatch.kt | 4 +-- 3 files changed, 18 insertions(+), 27 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 f51779a15a..a4e15faf7e 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 @@ -45,61 +45,48 @@ public enum ClientType { * 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, + IOS_MUSIC(26, + "IOS_MUSIC", + "iPhone16,2", + "17.5.1.21F90", + "com.google.ios.youtubemusic/7.08.2 (iPhone16,2; U; CPU iOS 17_5_1 like Mac OS X;)", + null, + "7.08.2", + true, false); - private static boolean forceAVC() { - return BaseSettings.SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC.get(); - } - /** * YouTube * client type */ public final int id; - public final String clientName; - /** * Device model, equivalent to {@link Build#MODEL} (System property: ro.product.model) */ public final String deviceModel; - /** * Device OS version. */ public final String osVersion; - /** * Player user-agent. */ public final String userAgent; - /** * Android SDK version, equivalent to {@link Build.VERSION#SDK} (System property: ro.build.version.sdk) * Field is null if not applicable. */ @Nullable public final String androidSdkVersion; - /** * App version. */ public final String clientVersion; - /** * If the client can access the API logged in. */ public final boolean canLogin; - /** * If a language code should be used. */ @@ -124,4 +111,8 @@ private static boolean forceAVC() { this.canLogin = canLogin; this.useLanguageCode = useLanguageCode; } + + private static boolean forceAVC() { + return BaseSettings.SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC.get(); + } } 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 5ad672f126..94f7efa56a 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 @@ -23,11 +23,11 @@ public class SpoofVideoStreamsPatch { private static final Uri UNREACHABLE_HOST_URI = Uri.parse(UNREACHABLE_HOST_URI_STRING); /** - * Injection point. Used by YT Music to disable stable volume. + * Injection point. Used by YT Music. */ - public static void setClientTypeToAndroidVrNoHl() { - Logger.printDebug(() -> "Setting stream spoofing to: " + ClientType.ANDROID_VR_NO_HL); - BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.save(ClientType.ANDROID_VR_NO_HL); + public static void setClientTypeToIosMusic() { + Logger.printDebug(() -> "Setting stream spoofing to: " + ClientType.IOS_MUSIC); + BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.save(ClientType.IOS_MUSIC); } /** 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 573ac0c154..600cd81767 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 @@ -10,6 +10,6 @@ val spoofVideoStreamsPatch = spoofVideoStreamsPatch({ }, { musicActivityOnCreateFingerprint.method.addInstruction( 0, - "invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->setClientTypeToAndroidVrNoHl()V" + "invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->setClientTypeToIosMusic()V", ) -}) \ No newline at end of file +})