Skip to content

Commit 8266c37

Browse files
1fexdLisoUseInAIKyrios
authored andcommitted
chore: Move Sync video downloads patch to correct package
1 parent fac5484 commit 8266c37

File tree

4 files changed

+68
-46
lines changed

4 files changed

+68
-46
lines changed

patches/api/patches.api

+4
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,10 @@ public final class app/revanced/patches/reddit/customclients/sync/syncforreddit/
503503
public static final fun getUseUserEndpointPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
504504
}
505505

506+
public final class app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/video/FixVideoDownloadsPatchKt {
507+
public static final fun getFixVideoDownloadsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
508+
}
509+
506510
public final class app/revanced/patches/reddit/customclients/syncforreddit/fix/video/FixVideoDownloadsPatchKt {
507511
public static final fun getFixVideoDownloadsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
508512
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.patches.reddit.customclients.syncforreddit.fix.video
1+
package app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.video
22

33
import app.revanced.patcher.fingerprint
44
import com.android.tools.smali.dexlib2.Opcode
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.video
2+
3+
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
4+
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
5+
import app.revanced.patcher.patch.bytecodePatch
6+
import app.revanced.patches.reddit.customclients.sync.syncforreddit.extension.sharedExtensionPatch
7+
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
8+
9+
private const val EXTENSION_CLASS_DESCRIPTOR =
10+
"Lapp/revanced/extension/syncforreddit/FixRedditVideoDownloadPatch;"
11+
private const val GET_LINKS_METHOD = "getLinks([B)[Ljava/lang/String;"
12+
13+
@Suppress("unused")
14+
val fixVideoDownloadsPatch = bytecodePatch(
15+
name = "Fix video downloads",
16+
description = "Fixes a bug in Sync's MPD parser resulting in only the audio-track being saved.",
17+
) {
18+
dependsOn(sharedExtensionPatch)
19+
20+
compatibleWith(
21+
"com.laurencedawson.reddit_sync",
22+
"com.laurencedawson.reddit_sync.pro",
23+
"com.laurencedawson.reddit_sync.dev",
24+
)
25+
26+
execute {
27+
val scanResult = parseRedditVideoNetworkResponseFingerprint.patternMatch!!
28+
val newInstanceIndex = scanResult.startIndex
29+
val invokeDirectIndex = scanResult.endIndex - 1
30+
31+
val buildResponseInstruction =
32+
parseRedditVideoNetworkResponseFingerprint.method.getInstruction<Instruction35c>(invokeDirectIndex)
33+
34+
parseRedditVideoNetworkResponseFingerprint.method.addInstructions(
35+
newInstanceIndex + 1,
36+
"""
37+
# Get byte array from response.
38+
iget-object v2, p1, Lcom/android/volley/NetworkResponse;->data:[B
39+
40+
# Parse the videoUrl and audioUrl from the byte array.
41+
invoke-static { v2 }, $EXTENSION_CLASS_DESCRIPTOR->$GET_LINKS_METHOD
42+
move-result-object v2
43+
44+
# Get videoUrl (Index 0).
45+
const/4 v5, 0x0
46+
aget-object v${buildResponseInstruction.registerE}, v2, v5
47+
48+
# Get audioUrl (Index 1).
49+
const/4 v6, 0x1
50+
aget-object v${buildResponseInstruction.registerF}, v2, v6
51+
52+
# Register E and F are used to build the response.
53+
""",
54+
)
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,18 @@
11
package app.revanced.patches.reddit.customclients.syncforreddit.fix.video
22

3-
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
4-
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
53
import app.revanced.patcher.patch.bytecodePatch
6-
import app.revanced.patches.reddit.customclients.sync.syncforreddit.extension.sharedExtensionPatch
7-
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
8-
9-
private const val EXTENSION_CLASS_DESCRIPTOR =
10-
"Lapp/revanced/extension/syncforreddit/FixRedditVideoDownloadPatch;"
11-
private const val GET_LINKS_METHOD = "getLinks([B)[Ljava/lang/String;"
124

5+
@Deprecated(
6+
message = "Patch was move to a different package",
7+
ReplaceWith("app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.video.fixVideoDownloadsPatch")
8+
)
139
@Suppress("unused")
14-
val fixVideoDownloadsPatch = bytecodePatch(
15-
name = "Fix video downloads",
16-
description = "Fixes a bug in Sync's MPD parser resulting in only the audio-track being saved.",
17-
) {
18-
dependsOn(sharedExtensionPatch)
10+
val fixVideoDownloadsPatch = bytecodePatch {
11+
dependsOn(app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.video.fixVideoDownloadsPatch)
1912

2013
compatibleWith(
2114
"com.laurencedawson.reddit_sync",
2215
"com.laurencedawson.reddit_sync.pro",
2316
"com.laurencedawson.reddit_sync.dev",
2417
)
25-
26-
execute {
27-
val scanResult = parseRedditVideoNetworkResponseFingerprint.patternMatch!!
28-
val newInstanceIndex = scanResult.startIndex
29-
val invokeDirectIndex = scanResult.endIndex - 1
30-
31-
val buildResponseInstruction =
32-
parseRedditVideoNetworkResponseFingerprint.method.getInstruction<Instruction35c>(invokeDirectIndex)
33-
34-
parseRedditVideoNetworkResponseFingerprint.method.addInstructions(
35-
newInstanceIndex + 1,
36-
"""
37-
# Get byte array from response.
38-
iget-object v2, p1, Lcom/android/volley/NetworkResponse;->data:[B
39-
40-
# Parse the videoUrl and audioUrl from the byte array.
41-
invoke-static { v2 }, $EXTENSION_CLASS_DESCRIPTOR->$GET_LINKS_METHOD
42-
move-result-object v2
43-
44-
# Get videoUrl (Index 0).
45-
const/4 v5, 0x0
46-
aget-object v${buildResponseInstruction.registerE}, v2, v5
47-
48-
# Get audioUrl (Index 1).
49-
const/4 v6, 0x1
50-
aget-object v${buildResponseInstruction.registerF}, v2, v6
51-
52-
# Register E and F are used to build the response.
53-
""",
54-
)
55-
}
56-
}
18+
}

0 commit comments

Comments
 (0)