diff --git a/patches/api/patches.api b/patches/api/patches.api index 1bed18e28..1da26f5b2 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -503,6 +503,10 @@ public final class app/revanced/patches/reddit/customclients/sync/syncforreddit/ public static final fun getUseUserEndpointPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/video/FixVideoDownloadsPatchKt { + public static final fun getFixVideoDownloadsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/reddit/customclients/syncforreddit/fix/video/FixVideoDownloadsPatchKt { public static final fun getFixVideoDownloadsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/video/Fingerprints.kt similarity index 84% rename from patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/Fingerprints.kt rename to patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/video/Fingerprints.kt index 3123563ee..9ddeaf9cf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/video/Fingerprints.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.reddit.customclients.syncforreddit.fix.video +package app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.video import app.revanced.patcher.fingerprint import com.android.tools.smali.dexlib2.Opcode diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/video/FixVideoDownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/video/FixVideoDownloadsPatch.kt new file mode 100644 index 000000000..64c33f308 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/video/FixVideoDownloadsPatch.kt @@ -0,0 +1,56 @@ +package app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.video + +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patches.reddit.customclients.sync.syncforreddit.extension.sharedExtensionPatch +import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c + +private const val EXTENSION_CLASS_DESCRIPTOR = + "Lapp/revanced/extension/syncforreddit/FixRedditVideoDownloadPatch;" +private const val GET_LINKS_METHOD = "getLinks([B)[Ljava/lang/String;" + +@Suppress("unused") +val fixVideoDownloadsPatch = bytecodePatch( + name = "Fix video downloads", + description = "Fixes a bug in Sync's MPD parser resulting in only the audio-track being saved.", +) { + dependsOn(sharedExtensionPatch) + + compatibleWith( + "com.laurencedawson.reddit_sync", + "com.laurencedawson.reddit_sync.pro", + "com.laurencedawson.reddit_sync.dev", + ) + + execute { + val scanResult = parseRedditVideoNetworkResponseFingerprint.patternMatch!! + val newInstanceIndex = scanResult.startIndex + val invokeDirectIndex = scanResult.endIndex - 1 + + val buildResponseInstruction = + parseRedditVideoNetworkResponseFingerprint.method.getInstruction(invokeDirectIndex) + + parseRedditVideoNetworkResponseFingerprint.method.addInstructions( + newInstanceIndex + 1, + """ + # Get byte array from response. + iget-object v2, p1, Lcom/android/volley/NetworkResponse;->data:[B + + # Parse the videoUrl and audioUrl from the byte array. + invoke-static { v2 }, $EXTENSION_CLASS_DESCRIPTOR->$GET_LINKS_METHOD + move-result-object v2 + + # Get videoUrl (Index 0). + const/4 v5, 0x0 + aget-object v${buildResponseInstruction.registerE}, v2, v5 + + # Get audioUrl (Index 1). + const/4 v6, 0x1 + aget-object v${buildResponseInstruction.registerF}, v2, v6 + + # Register E and F are used to build the response. + """, + ) + } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/FixVideoDownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/FixVideoDownloadsPatch.kt index 9990af83f..28ad4a0db 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/FixVideoDownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/FixVideoDownloadsPatch.kt @@ -1,56 +1,18 @@ package app.revanced.patches.reddit.customclients.syncforreddit.fix.video -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.reddit.customclients.sync.syncforreddit.extension.sharedExtensionPatch -import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c - -private const val EXTENSION_CLASS_DESCRIPTOR = - "Lapp/revanced/extension/syncforreddit/FixRedditVideoDownloadPatch;" -private const val GET_LINKS_METHOD = "getLinks([B)[Ljava/lang/String;" +@Deprecated( + message = "Patch was move to a different package", + ReplaceWith("app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.video.fixVideoDownloadsPatch") +) @Suppress("unused") -val fixVideoDownloadsPatch = bytecodePatch( - name = "Fix video downloads", - description = "Fixes a bug in Sync's MPD parser resulting in only the audio-track being saved.", -) { - dependsOn(sharedExtensionPatch) +val fixVideoDownloadsPatch = bytecodePatch { + dependsOn(app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.video.fixVideoDownloadsPatch) compatibleWith( "com.laurencedawson.reddit_sync", "com.laurencedawson.reddit_sync.pro", "com.laurencedawson.reddit_sync.dev", ) - - execute { - val scanResult = parseRedditVideoNetworkResponseFingerprint.patternMatch!! - val newInstanceIndex = scanResult.startIndex - val invokeDirectIndex = scanResult.endIndex - 1 - - val buildResponseInstruction = - parseRedditVideoNetworkResponseFingerprint.method.getInstruction(invokeDirectIndex) - - parseRedditVideoNetworkResponseFingerprint.method.addInstructions( - newInstanceIndex + 1, - """ - # Get byte array from response. - iget-object v2, p1, Lcom/android/volley/NetworkResponse;->data:[B - - # Parse the videoUrl and audioUrl from the byte array. - invoke-static { v2 }, $EXTENSION_CLASS_DESCRIPTOR->$GET_LINKS_METHOD - move-result-object v2 - - # Get videoUrl (Index 0). - const/4 v5, 0x0 - aget-object v${buildResponseInstruction.registerE}, v2, v5 - - # Get audioUrl (Index 1). - const/4 v6, 0x1 - aget-object v${buildResponseInstruction.registerF}, v2, v6 - - # Register E and F are used to build the response. - """, - ) - } -} +} \ No newline at end of file