Skip to content

Commit 7f852e8

Browse files
committed
fix(YouTube Music): Fix compatibility with latest versions (#2924)
1 parent 5b7b134 commit 7f852e8

22 files changed

+316
-356
lines changed

api/revanced-patches.api

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ public final class app/revanced/patches/moneymanager/UnlockProPatch : app/revanc
302302
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
303303
}
304304

305+
public final class app/revanced/patches/music/ad/video/HideMusicVideoAds : app/revanced/patcher/patch/BytecodePatch {
306+
public static final field INSTANCE Lapp/revanced/patches/music/ad/video/HideMusicVideoAds;
307+
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
308+
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
309+
}
310+
305311
public final class app/revanced/patches/music/ad/video/MusicVideoAdsPatch : app/revanced/patcher/patch/BytecodePatch {
306312
public static final field INSTANCE Lapp/revanced/patches/music/ad/video/MusicVideoAdsPatch;
307313
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
@@ -314,6 +320,12 @@ public final class app/revanced/patches/music/audio/codecs/CodecsUnlockPatch : a
314320
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
315321
}
316322

323+
public final class app/revanced/patches/music/audio/exclusiveaudio/EnableExclusiveAudioPlayback : app/revanced/patcher/patch/BytecodePatch {
324+
public static final field INSTANCE Lapp/revanced/patches/music/audio/exclusiveaudio/EnableExclusiveAudioPlayback;
325+
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
326+
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
327+
}
328+
317329
public final class app/revanced/patches/music/audio/exclusiveaudio/ExclusiveAudioPatch : app/revanced/patcher/patch/BytecodePatch {
318330
public static final field INSTANCE Lapp/revanced/patches/music/audio/exclusiveaudio/ExclusiveAudioPatch;
319331
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
@@ -326,6 +338,12 @@ public final class app/revanced/patches/music/interaction/permanentrepeat/Perman
326338
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
327339
}
328340

341+
public final class app/revanced/patches/music/interaction/permanentshuffle/PermanentShufflePatch : app/revanced/patcher/patch/BytecodePatch {
342+
public static final field INSTANCE Lapp/revanced/patches/music/interaction/permanentshuffle/PermanentShufflePatch;
343+
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
344+
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
345+
}
346+
329347
public final class app/revanced/patches/music/interaction/permanentshuffle/PermanentShuffleTogglePatch : app/revanced/patcher/patch/BytecodePatch {
330348
public static final field INSTANCE Lapp/revanced/patches/music/interaction/permanentshuffle/PermanentShuffleTogglePatch;
331349
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
@@ -338,6 +356,12 @@ public final class app/revanced/patches/music/layout/compactheader/CompactHeader
338356
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
339357
}
340358

359+
public final class app/revanced/patches/music/layout/compactheader/HideCategoryBar : app/revanced/patcher/patch/BytecodePatch {
360+
public static final field INSTANCE Lapp/revanced/patches/music/layout/compactheader/HideCategoryBar;
361+
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
362+
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
363+
}
364+
341365
public final class app/revanced/patches/music/layout/minimizedplayback/MinimizedPlaybackPatch : app/revanced/patcher/patch/BytecodePatch {
342366
public static final field INSTANCE Lapp/revanced/patches/music/layout/minimizedplayback/MinimizedPlaybackPatch;
343367
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package app.revanced.patches.music.ad.video
2+
3+
import app.revanced.patcher.data.BytecodeContext
4+
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
5+
import app.revanced.patcher.patch.BytecodePatch
6+
import app.revanced.patcher.patch.annotation.CompatiblePackage
7+
import app.revanced.patcher.patch.annotation.Patch
8+
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
9+
import app.revanced.patches.music.ad.video.fingerprints.ShowMusicVideoAdsParentFingerprint
10+
import app.revanced.util.exception
11+
12+
@Patch(
13+
name = "Hide music video ads",
14+
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")],
15+
)
16+
@Suppress("unused")
17+
object HideMusicVideoAds : BytecodePatch(
18+
setOf(ShowMusicVideoAdsParentFingerprint),
19+
) {
20+
override fun execute(context: BytecodeContext) {
21+
ShowMusicVideoAdsParentFingerprint.result?.let {
22+
val showMusicVideoAdsMethod = context
23+
.toMethodWalker(it.mutableMethod)
24+
.nextMethod(it.scanResult.patternScanResult!!.startIndex + 1, true).getMethod() as MutableMethod
25+
26+
showMusicVideoAdsMethod.addInstruction(0, "const/4 p1, 0x0")
27+
} ?: throw ShowMusicVideoAdsParentFingerprint.exception
28+
}
29+
}
30+
31+
@Deprecated("This patch class has been renamed to HideMusicVideoAds.")
32+
object MusicVideoAdsPatch : BytecodePatch(
33+
dependencies = setOf(HideMusicVideoAds::class),
34+
) {
35+
override fun execute(context: BytecodeContext) {
36+
}
37+
}

src/main/kotlin/app/revanced/patches/music/ad/video/MusicVideoAdsPatch.kt

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsConstructorFingerprint.kt

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsFingerprint.kt

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package app.revanced.patches.music.ad.video.fingerprints
2+
3+
import app.revanced.patcher.fingerprint.MethodFingerprint
4+
import com.android.tools.smali.dexlib2.Opcode
5+
6+
internal object ShowMusicVideoAdsParentFingerprint : MethodFingerprint(
7+
opcodes = listOf(
8+
Opcode.MOVE_RESULT_OBJECT,
9+
Opcode.INVOKE_VIRTUAL,
10+
Opcode.IGET_OBJECT,
11+
),
12+
strings = listOf("maybeRegenerateCpnAndStatsClient called unexpectedly, but no error."),
13+
)

src/main/kotlin/app/revanced/patches/music/audio/codecs/CodecsUnlockPatch.kt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ import app.revanced.patches.music.audio.codecs.fingerprints.CodecsLockFingerprin
1010
import com.android.tools.smali.dexlib2.Opcode
1111

1212
@Patch(
13-
name = "Codecs unlock",
1413
description = "Adds more audio codec options. The new audio codecs usually result in better audio quality.",
15-
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")]
14+
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")],
1615
)
17-
@Suppress("unused")
16+
@Deprecated("This patch is no longer needed as the feature is now enabled by default.")
1817
object CodecsUnlockPatch : BytecodePatch(
19-
setOf(CodecsLockFingerprint, AllCodecsReferenceFingerprint)
18+
setOf(CodecsLockFingerprint, AllCodecsReferenceFingerprint),
2019
) {
2120
override fun execute(context: BytecodeContext) {
2221
val codecsLockResult = CodecsLockFingerprint.result!!
@@ -25,13 +24,13 @@ object CodecsUnlockPatch : BytecodePatch(
2524

2625
val scanResultStartIndex = codecsLockResult.scanResult.patternScanResult!!.startIndex
2726
val instructionIndex = scanResultStartIndex +
28-
if (implementation.instructions[scanResultStartIndex - 1].opcode == Opcode.CHECK_CAST) {
29-
// for 5.16.xx and lower
30-
-3
31-
} else {
32-
// since 5.17.xx
33-
-2
34-
}
27+
if (implementation.instructions[scanResultStartIndex - 1].opcode == Opcode.CHECK_CAST) {
28+
// for 5.16.xx and lower
29+
-3
30+
} else {
31+
// since 5.17.xx
32+
-2
33+
}
3534

3635
val allCodecsResult = AllCodecsReferenceFingerprint.result!!
3736
val allCodecsMethod =
@@ -41,7 +40,7 @@ object CodecsUnlockPatch : BytecodePatch(
4140

4241
implementation.replaceInstruction(
4342
instructionIndex,
44-
"invoke-static {}, ${allCodecsMethod.definingClass}->${allCodecsMethod.name}()Ljava/util/Set;".toInstruction()
43+
"invoke-static {}, ${allCodecsMethod.definingClass}->${allCodecsMethod.name}()Ljava/util/Set;".toInstruction(),
4544
)
4645
}
4746
}
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
package app.revanced.patches.music.audio.exclusiveaudio
22

3-
import app.revanced.util.exception
43
import app.revanced.patcher.data.BytecodeContext
54
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
65
import app.revanced.patcher.patch.BytecodePatch
76
import app.revanced.patcher.patch.annotation.CompatiblePackage
87
import app.revanced.patcher.patch.annotation.Patch
98
import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AllowExclusiveAudioPlaybackFingerprint
9+
import app.revanced.util.exception
1010

1111
@Patch(
12-
name = "Exclusive audio playback",
12+
name = "Enable exclusive audio playback",
1313
description = "Enables the option to play audio without video.",
14-
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")]
14+
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")],
1515
)
1616
@Suppress("unused")
17-
object ExclusiveAudioPatch : BytecodePatch(
18-
setOf(AllowExclusiveAudioPlaybackFingerprint)
17+
object EnableExclusiveAudioPlayback : BytecodePatch(
18+
setOf(AllowExclusiveAudioPlaybackFingerprint),
1919
) {
2020
override fun execute(context: BytecodeContext) {
2121
AllowExclusiveAudioPlaybackFingerprint.result?.mutableMethod?.apply {
2222
addInstructions(
2323
0,
24-
"""
24+
"""
2525
const/4 v0, 0x1
2626
return v0
27-
"""
27+
""",
2828
)
2929
} ?: throw AllowExclusiveAudioPlaybackFingerprint.exception
3030
}
31-
}
31+
}
32+
33+
@Deprecated("This patch class has been renamed to EnableExclusiveAudioPlayback.")
34+
object ExclusiveAudioPatch : BytecodePatch(emptySet()) {
35+
override fun execute(context: BytecodeContext) = EnableExclusiveAudioPlayback.execute(context)
36+
}
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
package app.revanced.patches.music.interaction.permanentshuffle
22

3-
import app.revanced.util.exception
43
import app.revanced.patcher.data.BytecodeContext
54
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
65
import app.revanced.patcher.patch.BytecodePatch
76
import app.revanced.patcher.patch.annotation.CompatiblePackage
87
import app.revanced.patcher.patch.annotation.Patch
98
import app.revanced.patches.music.interaction.permanentshuffle.fingerprints.DisableShuffleFingerprint
10-
9+
import app.revanced.util.exception
1110

1211
@Patch(
1312
name = "Permanent shuffle",
1413
description = "Permanently remember your shuffle preference " +
15-
"even if the playlist ends or another track is played.",
14+
"even if the playlist ends or another track is played.",
1615
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")],
17-
use = false
16+
use = false,
1817
)
1918
@Suppress("unused")
20-
object PermanentShuffleTogglePatch : BytecodePatch(setOf(DisableShuffleFingerprint)) {
19+
object PermanentShufflePatch : BytecodePatch(setOf(DisableShuffleFingerprint)) {
2120
override fun execute(context: BytecodeContext) {
2221
DisableShuffleFingerprint.result?.mutableMethod?.addInstruction(0, "return-void")
2322
?: throw DisableShuffleFingerprint.exception
2423
}
2524
}
25+
26+
@Deprecated("This patch class has been renamed to PermanentShufflePatch.")
27+
object PermanentShuffleTogglePatch : BytecodePatch(
28+
dependencies = setOf(PermanentShufflePatch::class),
29+
) {
30+
override fun execute(context: BytecodeContext) {
31+
}
32+
}

src/main/kotlin/app/revanced/patches/music/layout/compactheader/CompactHeaderPatch.kt

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)