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:
Yan 2024-06-08 19:42:45 +03:00 committed by GitHub
parent 561a202bff
commit a9258d48d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 51 additions and 0 deletions

View file

@ -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;
} }

View file

@ -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\"")
}
}
}
}
}

View file

@ -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", "/"),
)