feat(Boost for Reddit): Add Fix audio missing in video downloads
patch (#3287)
Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
561a202bff
commit
a9258d48d3
|
@ -582,6 +582,12 @@ public final class app/revanced/patches/reddit/customclients/boostforreddit/api/
|
||||||
public fun patchUserAgent (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V
|
public fun patchUserAgent (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch : app/revanced/patcher/patch/BytecodePatch {
|
||||||
|
public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch;
|
||||||
|
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
|
||||||
|
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||||
|
}
|
||||||
|
|
||||||
public final class app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch : app/revanced/patches/reddit/customclients/BaseFixSLinksPatch {
|
public final class app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch : app/revanced/patches/reddit/customclients/BaseFixSLinksPatch {
|
||||||
public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch;
|
public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package app.revanced.patches.reddit.customclients.boostforreddit.fix.downloads
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patches.reddit.customclients.boostforreddit.fix.downloads.fingerprints.DownloadAudioFingerprint
|
||||||
|
import app.revanced.util.resultOrThrow
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
|
@Patch(
|
||||||
|
name = "Fix missing audio in video downloads",
|
||||||
|
description = "Fixes audio missing in videos downloaded from v.redd.it.",
|
||||||
|
compatiblePackages = [CompatiblePackage("com.rubenmayayo.reddit")],
|
||||||
|
)
|
||||||
|
@Suppress("unused")
|
||||||
|
object FixAudioMissingInDownloadsPatch : BytecodePatch(
|
||||||
|
setOf(DownloadAudioFingerprint),
|
||||||
|
) {
|
||||||
|
private val endpointReplacements = mapOf(
|
||||||
|
"/DASH_audio.mp4" to "/DASH_AUDIO_128.mp4",
|
||||||
|
"/audio" to "/DASH_AUDIO_64.mp4",
|
||||||
|
)
|
||||||
|
override fun execute(context: BytecodeContext) {
|
||||||
|
DownloadAudioFingerprint.resultOrThrow().let { result ->
|
||||||
|
result.scanResult.stringsScanResult!!.matches.take(2).forEach { match ->
|
||||||
|
result.mutableMethod.apply {
|
||||||
|
val replacement = endpointReplacements[match.string]
|
||||||
|
val register = getInstruction<OneRegisterInstruction>(match.index).registerA
|
||||||
|
|
||||||
|
replaceInstruction(match.index, "const-string v$register, \"$replacement\"")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package app.revanced.patches.reddit.customclients.boostforreddit.fix.downloads.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
|
||||||
|
internal object DownloadAudioFingerprint : MethodFingerprint(
|
||||||
|
strings = setOf("/DASH_audio.mp4", "/audio", "v.redd.it", "/"),
|
||||||
|
)
|
Loading…
Reference in a new issue