Skip to content

Commit 2ea583c

Browse files
OctoNezdLisoUseInAIKyriosoSumAtrIX
authored
feat(Boost for Reddit): Add Fix audio missing in video downloads patch (#3287)
Co-authored-by: LisoUseInAIKyrios <[email protected]> Co-authored-by: oSumAtrIX <[email protected]>
1 parent 8dda898 commit 2ea583c

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

api/revanced-patches.api

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,12 @@ public final class app/revanced/patches/reddit/customclients/boostforreddit/api/
582582
public fun patchUserAgent (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V
583583
}
584584

585+
public final class app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch : app/revanced/patcher/patch/BytecodePatch {
586+
public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch;
587+
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
588+
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
589+
}
590+
585591
public final class app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch : app/revanced/patches/reddit/customclients/BaseFixSLinksPatch {
586592
public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch;
587593
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package app.revanced.patches.reddit.customclients.boostforreddit.fix.downloads
2+
3+
import app.revanced.patcher.data.BytecodeContext
4+
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
5+
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
6+
import app.revanced.patcher.patch.BytecodePatch
7+
import app.revanced.patcher.patch.annotation.CompatiblePackage
8+
import app.revanced.patcher.patch.annotation.Patch
9+
import app.revanced.patches.reddit.customclients.boostforreddit.fix.downloads.fingerprints.DownloadAudioFingerprint
10+
import app.revanced.util.resultOrThrow
11+
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
12+
13+
@Patch(
14+
name = "Fix missing audio in video downloads",
15+
description = "Fixes audio missing in videos downloaded from v.redd.it.",
16+
compatiblePackages = [CompatiblePackage("com.rubenmayayo.reddit")],
17+
)
18+
@Suppress("unused")
19+
object FixAudioMissingInDownloadsPatch : BytecodePatch(
20+
setOf(DownloadAudioFingerprint),
21+
) {
22+
private val endpointReplacements = mapOf(
23+
"/DASH_audio.mp4" to "/DASH_AUDIO_128.mp4",
24+
"/audio" to "/DASH_AUDIO_64.mp4",
25+
)
26+
override fun execute(context: BytecodeContext) {
27+
DownloadAudioFingerprint.resultOrThrow().let { result ->
28+
result.scanResult.stringsScanResult!!.matches.take(2).forEach { match ->
29+
result.mutableMethod.apply {
30+
val replacement = endpointReplacements[match.string]
31+
val register = getInstruction<OneRegisterInstruction>(match.index).registerA
32+
33+
replaceInstruction(match.index, "const-string v$register, \"$replacement\"")
34+
}
35+
}
36+
}
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package app.revanced.patches.reddit.customclients.boostforreddit.fix.downloads.fingerprints
2+
3+
import app.revanced.patcher.fingerprint.MethodFingerprint
4+
5+
internal object DownloadAudioFingerprint : MethodFingerprint(
6+
strings = setOf("/DASH_audio.mp4", "/audio", "v.redd.it", "/"),
7+
)

0 commit comments

Comments
 (0)