-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(YouTube Music - Disable auto captions): Captions cannot be change…
…d when `Disable forced auto captions` is turned on
- Loading branch information
Showing
7 changed files
with
72 additions
and
66 deletions.
There are no files selected for viewing
25 changes: 5 additions & 20 deletions
25
src/main/kotlin/app/revanced/patches/music/general/autocaptions/AutoCaptionsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/kotlin/app/revanced/patches/shared/captions/BaseAutoCaptionsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package app.revanced.patches.shared.captions | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patcher.util.smali.ExternalLabel | ||
import app.revanced.patches.shared.captions.fingerprints.StoryboardRendererDecoderRecommendedLevelFingerprint | ||
import app.revanced.patches.shared.captions.fingerprints.SubtitleTrackFingerprint | ||
import app.revanced.patches.shared.fingerprints.StartVideoInformerFingerprint | ||
import app.revanced.patches.shared.integrations.Constants.PATCHES_PATH | ||
import app.revanced.util.resultOrThrow | ||
|
||
@Patch( | ||
description = "Disable forced auto captions for YouTube or YouTube Music." | ||
) | ||
object BaseAutoCaptionsPatch : BytecodePatch( | ||
setOf( | ||
StartVideoInformerFingerprint, | ||
StoryboardRendererDecoderRecommendedLevelFingerprint, | ||
SubtitleTrackFingerprint, | ||
) | ||
) { | ||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = | ||
"$PATCHES_PATH/AutoCaptionsPatch;" | ||
|
||
override fun execute(context: BytecodeContext) { | ||
|
||
SubtitleTrackFingerprint.resultOrThrow().mutableMethod.apply { | ||
addInstructionsWithLabels( | ||
0, """ | ||
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->disableAutoCaptions()Z | ||
move-result v0 | ||
if-eqz v0, :disabled | ||
const/4 v0, 0x1 | ||
return v0 | ||
""", ExternalLabel("disabled", getInstruction(0)) | ||
) | ||
} | ||
|
||
mapOf( | ||
StartVideoInformerFingerprint to 0, | ||
StoryboardRendererDecoderRecommendedLevelFingerprint to 1 | ||
).forEach { (fingerprint, enabled) -> | ||
fingerprint.resultOrThrow().mutableMethod.addInstructions( | ||
0, """ | ||
const/4 v0, 0x$enabled | ||
invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->setCaptionsButtonStatus(Z)V | ||
""" | ||
) | ||
} | ||
|
||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
...ererDecoderRecommendedLevelFingerprint.kt → ...ererDecoderRecommendedLevelFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
package app.revanced.patches.youtube.general.autocaptions.fingerprints | ||
package app.revanced.patches.shared.captions.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import app.revanced.patches.youtube.utils.PlayerResponseModelUtils.PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
|
||
internal object StoryboardRendererDecoderRecommendedLevelFingerprint : MethodFingerprint( | ||
returnType = "V", | ||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, | ||
parameters = listOf(PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR), | ||
parameters = listOf("L"), | ||
strings = listOf("#-1#") | ||
) |
2 changes: 1 addition & 1 deletion
2
.../fingerprints/SubtitleTrackFingerprint.kt → .../fingerprints/SubtitleTrackFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...erprints/StartVideoInformerFingerprint.kt → ...erprints/StartVideoInformerFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 6 additions & 40 deletions
46
src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/AutoCaptionsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters