fix(YouTube/Spoof client): change default value

This commit is contained in:
inotia00 2024-08-07 13:42:19 +09:00
parent 33117ba96e
commit 47044f09c9
4 changed files with 64 additions and 55 deletions

View File

@ -8,7 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint
@ -16,7 +15,6 @@ import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModel
import app.revanced.patches.youtube.misc.backgroundplayback.BackgroundPlaybackPatch import app.revanced.patches.youtube.misc.backgroundplayback.BackgroundPlaybackPatch
import app.revanced.patches.youtube.utils.compatibility.Constants import app.revanced.patches.youtube.utils.compatibility.Constants
import app.revanced.patches.youtube.utils.fingerprints.PlaybackRateBottomSheetBuilderFingerprint import app.revanced.patches.youtube.utils.fingerprints.PlaybackRateBottomSheetBuilderFingerprint
import app.revanced.patches.youtube.utils.fix.client.fingerprints.BackgroundPlaybackPlayerResponseFingerprint
import app.revanced.patches.youtube.utils.fix.client.fingerprints.BuildInitPlaybackRequestFingerprint import app.revanced.patches.youtube.utils.fix.client.fingerprints.BuildInitPlaybackRequestFingerprint
import app.revanced.patches.youtube.utils.fix.client.fingerprints.BuildPlaybackStatsRequestURIFingerprint import app.revanced.patches.youtube.utils.fix.client.fingerprints.BuildPlaybackStatsRequestURIFingerprint
import app.revanced.patches.youtube.utils.fix.client.fingerprints.BuildPlayerRequestURIFingerprint import app.revanced.patches.youtube.utils.fix.client.fingerprints.BuildPlayerRequestURIFingerprint
@ -27,6 +25,7 @@ import app.revanced.patches.youtube.utils.fix.client.fingerprints.CreatePlayerRe
import app.revanced.patches.youtube.utils.fix.client.fingerprints.NerdsStatsVideoFormatBuilderFingerprint import app.revanced.patches.youtube.utils.fix.client.fingerprints.NerdsStatsVideoFormatBuilderFingerprint
import app.revanced.patches.youtube.utils.fix.client.fingerprints.OrganicPlaybackContextModelFingerprint import app.revanced.patches.youtube.utils.fix.client.fingerprints.OrganicPlaybackContextModelFingerprint
import app.revanced.patches.youtube.utils.fix.client.fingerprints.PlayerGestureConfigSyntheticFingerprint import app.revanced.patches.youtube.utils.fix.client.fingerprints.PlayerGestureConfigSyntheticFingerprint
import app.revanced.patches.youtube.utils.fix.client.fingerprints.PlayerResponseModelBackgroundAudioPlaybackFingerprint
import app.revanced.patches.youtube.utils.fix.client.fingerprints.SetPlayerRequestClientTypeFingerprint import app.revanced.patches.youtube.utils.fix.client.fingerprints.SetPlayerRequestClientTypeFingerprint
import app.revanced.patches.youtube.utils.fix.client.fingerprints.UserAgentHeaderBuilderFingerprint import app.revanced.patches.youtube.utils.fix.client.fingerprints.UserAgentHeaderBuilderFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH
@ -59,7 +58,7 @@ object SpoofClientPatch : BaseBytecodePatch(
name = "Spoof client", name = "Spoof client",
description = "Adds options to spoof the client to allow video playback.", description = "Adds options to spoof the client to allow video playback.",
dependencies = setOf( dependencies = setOf(
// Required to fix background playback issue of live stream on iOS client. // Required since iOS livestream fix partially enables background playback.
BackgroundPlaybackPatch::class, BackgroundPlaybackPatch::class,
PlayerTypeHookPatch::class, PlayerTypeHookPatch::class,
@ -81,13 +80,6 @@ object SpoofClientPatch : BaseBytecodePatch(
CreatePlayerRequestBodyWithVersionReleaseFingerprint, CreatePlayerRequestBodyWithVersionReleaseFingerprint,
UserAgentHeaderBuilderFingerprint, UserAgentHeaderBuilderFingerprint,
// Background playback in live stream.
BackgroundPlaybackPlayerResponseFingerprint,
// Watch history.
BuildPlaybackStatsRequestURIFingerprint,
OrganicPlaybackContextModelFingerprint,
// Player gesture config. // Player gesture config.
PlayerGestureConfigSyntheticFingerprint, PlayerGestureConfigSyntheticFingerprint,
@ -95,6 +87,13 @@ object SpoofClientPatch : BaseBytecodePatch(
CreatePlaybackSpeedMenuItemFingerprint, CreatePlaybackSpeedMenuItemFingerprint,
PlaybackRateBottomSheetBuilderFingerprint, PlaybackRateBottomSheetBuilderFingerprint,
// Livestream audio only background playback.
PlayerResponseModelBackgroundAudioPlaybackFingerprint,
// Watch history.
BuildPlaybackStatsRequestURIFingerprint,
OrganicPlaybackContextModelFingerprint,
// Nerds stats video format. // Nerds stats video format.
NerdsStatsVideoFormatBuilderFingerprint, NerdsStatsVideoFormatBuilderFingerprint,
) )
@ -106,6 +105,10 @@ object SpoofClientPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
var settingArray = arrayOf(
"SETTINGS: SPOOF_CLIENT"
)
// region Block /initplayback requests to fall back to /get_watch requests. // region Block /initplayback requests to fall back to /get_watch requests.
BuildInitPlaybackRequestFingerprint.resultOrThrow().let { BuildInitPlaybackRequestFingerprint.resultOrThrow().let {
@ -401,22 +404,13 @@ object SpoofClientPatch : BaseBytecodePatch(
// endregion // endregion
// region fix background playback in live stream, if spoofing to iOS // region fix background playback in live stream, if spoofing to iOS
// This force enables audio background playback.
/** PlayerResponseModelBackgroundAudioPlaybackFingerprint.resultOrThrow().mutableMethod.apply {
* If the return value of this method is true, background playback is always enabled.
*
* If [BackgroundPlaybackPatch] is excluded, there may be unintended behavior.
* Therefore, [BackgroundPlaybackPatch] must be included.
*
* Also, [PlayerTypeHookPatch] is required to disable background playback in Shorts.
*/
BackgroundPlaybackPlayerResponseFingerprint.resultOrThrow().mutableMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
0, """ 0, """
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->forceEnableBackgroundPlayback()Z invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->overrideBackgroundAudioPlayback()Z
move-result v0 move-result v0
if-eqz v0, :disabled if-eqz v0, :disabled
const/4 v0, 0x1
return v0 return v0
""", ExternalLabel("disabled", getInstruction(0)) """, ExternalLabel("disabled", getInstruction(0))
) )
@ -426,10 +420,10 @@ object SpoofClientPatch : BaseBytecodePatch(
// region watch history if spoofing to iOS // region watch history if spoofing to iOS
if (!SettingsPatch.upward1839) {
BuildPlaybackStatsRequestURIFingerprint.resultOrThrow().let { BuildPlaybackStatsRequestURIFingerprint.resultOrThrow().let {
val walkerMethod = context.toMethodWalker(it.method) val walkerMethod =
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true) it.getWalkerMethod(context, it.scanResult.patternScanResult!!.startIndex)
.getMethod() as MutableMethod
walkerMethod.addInstructions( walkerMethod.addInstructions(
0, """ 0, """
@ -442,7 +436,8 @@ object SpoofClientPatch : BaseBytecodePatch(
OrganicPlaybackContextModelFingerprint.resultOrThrow().let { OrganicPlaybackContextModelFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex val insertIndex = it.scanResult.patternScanResult!!.endIndex
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA val insertRegister =
getInstruction<TwoRegisterInstruction>(insertIndex).registerA
addInstruction( addInstruction(
insertIndex, insertIndex,
@ -452,6 +447,7 @@ object SpoofClientPatch : BaseBytecodePatch(
} }
TrackingUrlHookPatch.hookTrackingUrl("$INTEGRATIONS_CLASS_DESCRIPTOR->setTrackingUriParameter(Landroid/net/Uri;)V") TrackingUrlHookPatch.hookTrackingUrl("$INTEGRATIONS_CLASS_DESCRIPTOR->setTrackingUriParameter(Landroid/net/Uri;)V")
}
// endregion // endregion
@ -482,16 +478,18 @@ object SpoofClientPatch : BaseBytecodePatch(
// endregion // endregion
if (!SettingsPatch.upward1839) {
settingArray += "SETTINGS: IOS_CLIENT_SIDE_EFFECT_1838"
} else {
settingArray += "SETTINGS: IOS_CLIENT_SIDE_EFFECT_1839"
context.updatePatchStatus(PATCH_STATUS_CLASS_DESCRIPTOR, "SpoofClient") context.updatePatchStatus(PATCH_STATUS_CLASS_DESCRIPTOR, "SpoofClient")
}
/** /**
* Add settings * Add settings
*/ */
SettingsPatch.addPreference( SettingsPatch.addPreference(settingArray)
arrayOf(
"SETTINGS: SPOOF_CLIENT"
)
)
SettingsPatch.updatePatchStatus(this) SettingsPatch.updatePatchStatus(this)
} }

View File

@ -11,7 +11,7 @@ import com.android.tools.smali.dexlib2.Opcode
* This fingerprint seems to break easily because there are many [Opcode] patterns, but it is not. * This fingerprint seems to break easily because there are many [Opcode] patterns, but it is not.
* This fingerprint has been tested on all versions from YouTube 17.34.36 to YouTube 19.29.42. * This fingerprint has been tested on all versions from YouTube 17.34.36 to YouTube 19.29.42.
*/ */
internal object BackgroundPlaybackPlayerResponseFingerprint : MethodFingerprint( internal object PlayerResponseModelBackgroundAudioPlaybackFingerprint : MethodFingerprint(
returnType = "Z", returnType = "Z",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("Lcom/google/android/libraries/youtube/innertube/model/player/PlayerResponseModel;"), parameters = listOf("Lcom/google/android/libraries/youtube/innertube/model/player/PlayerResponseModel;"),

View File

@ -1613,12 +1613,16 @@ Limitation: Feed videos will play for less than 1 minute before encountering pla
<string name="revanced_preference_category_spoof_client_about">About</string> <string name="revanced_preference_category_spoof_client_about">About</string>
<string name="revanced_spoof_client_use_ios_title">iOS</string> <string name="revanced_spoof_client_use_ios_title">iOS</string>
<string name="revanced_spoof_client_use_ios_legacy_summary">"Spoof client to iOS.
Side effects include:
• HDR video is supported only on AV1 codec.
• Watch time is not saved in watch history on brand account."</string>
<string name="revanced_spoof_client_use_ios_summary">"Spoof client to iOS. <string name="revanced_spoof_client_use_ios_summary">"Spoof client to iOS.
Side effects include: Side effects include:
• HDR video is supported only on AV1 codec. • HDR video is supported only on AV1 codec.
• Watch history does not work with a brand account. • Watch history does not work with a brand account."</string>
• Live streams cannot play as audio-only."</string>
<string name="revanced_spoof_client_use_android_testsuite_title">Android Testsuite</string> <string name="revanced_spoof_client_use_android_testsuite_title">Android Testsuite</string>
<string name="revanced_spoof_client_use_android_testsuite_summary">"Spoof client to Android Testsuite. <string name="revanced_spoof_client_use_android_testsuite_summary">"Spoof client to Android Testsuite.

View File

@ -619,8 +619,15 @@
<ListPreference android:entries="@array/revanced_spoof_client_shorts_options_entries" android:title="@string/revanced_spoof_client_shorts_title" android:key="revanced_spoof_client_shorts" android:entryValues="@array/revanced_spoof_client_shorts_options_entry_values" android:dependency="revanced_spoof_client" /> <ListPreference android:entries="@array/revanced_spoof_client_shorts_options_entries" android:title="@string/revanced_spoof_client_shorts_title" android:key="revanced_spoof_client_shorts" android:entryValues="@array/revanced_spoof_client_shorts_options_entry_values" android:dependency="revanced_spoof_client" />
<ListPreference android:entries="@array/revanced_spoof_client_fallback_options_entries" android:title="@string/revanced_spoof_client_fallback_title" android:key="revanced_spoof_client_fallback" android:entryValues="@array/revanced_spoof_client_fallback_options_entry_values" android:dependency="revanced_spoof_client" /> <ListPreference android:entries="@array/revanced_spoof_client_fallback_options_entries" android:title="@string/revanced_spoof_client_fallback_title" android:key="revanced_spoof_client_fallback" android:entryValues="@array/revanced_spoof_client_fallback_options_entry_values" android:dependency="revanced_spoof_client" />
<PreferenceCategory android:title="@string/revanced_preference_category_spoof_client_about" android:layout="@layout/revanced_settings_preferences_category" /> <PreferenceCategory android:title="@string/revanced_preference_category_spoof_client_about" android:layout="@layout/revanced_settings_preferences_category" />SETTINGS: SPOOF_CLIENT -->
<Preference android:title="@string/revanced_spoof_client_use_ios_title" android:key="revanced_spoof_client_use_ios" android:selectable="false" android:summary="@string/revanced_spoof_client_use_ios_summary" android:dependency="revanced_spoof_client" />
<!-- SETTINGS: IOS_CLIENT_SIDE_EFFECT_1838
<Preference android:title="@string/revanced_spoof_client_use_ios_title" android:key="revanced_spoof_client_use_ios" android:selectable="false" android:summary="@string/revanced_spoof_client_use_ios_legacy_summary" android:dependency="revanced_spoof_client" />SETTINGS: IOS_CLIENT_SIDE_EFFECT_1838 -->
<!-- SETTINGS: IOS_CLIENT_SIDE_EFFECT_1839
<Preference android:title="@string/revanced_spoof_client_use_ios_title" android:key="revanced_spoof_client_use_ios" android:selectable="false" android:summary="@string/revanced_spoof_client_use_ios_summary" android:dependency="revanced_spoof_client" />SETTINGS: IOS_CLIENT_SIDE_EFFECT_1839 -->
<!-- SETTINGS: SPOOF_CLIENT
<Preference android:title="@string/revanced_spoof_client_use_android_testsuite_title" android:key="revanced_spoof_client_use_android_testsuite" android:selectable="false" android:summary="@string/revanced_spoof_client_use_android_testsuite_summary" android:dependency="revanced_spoof_client" /> <Preference android:title="@string/revanced_spoof_client_use_android_testsuite_title" android:key="revanced_spoof_client_use_android_testsuite" android:selectable="false" android:summary="@string/revanced_spoof_client_use_android_testsuite_summary" android:dependency="revanced_spoof_client" />
<Preference android:title="@string/revanced_spoof_client_use_android_tv_title" android:key="revanced_spoof_client_use_android_tv" android:selectable="false" android:summary="@string/revanced_spoof_client_use_android_tv_summary" android:dependency="revanced_spoof_client" /> <Preference android:title="@string/revanced_spoof_client_use_android_tv_title" android:key="revanced_spoof_client_use_android_tv" android:selectable="false" android:summary="@string/revanced_spoof_client_use_android_tv_summary" android:dependency="revanced_spoof_client" />
<Preference android:title="@string/revanced_spoof_client_use_android_vr_title" android:key="revanced_spoof_client_use_android_vr" android:selectable="false" android:summary="@string/revanced_spoof_client_use_android_vr_summary" android:dependency="revanced_spoof_client" /> <Preference android:title="@string/revanced_spoof_client_use_android_vr_title" android:key="revanced_spoof_client_use_android_vr" android:selectable="false" android:summary="@string/revanced_spoof_client_use_android_vr_summary" android:dependency="revanced_spoof_client" />