mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-18 16:09:37 +01:00
feat(YouTube - External downloader): Add ability to use in-app download button
This commit is contained in:
parent
c4379c0e67
commit
d9000113a9
@ -1194,8 +1194,8 @@ public final class app/revanced/patches/youtube/interaction/dialog/RemoveViewerD
|
||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsBytecodePatch : app/revanced/patcher/patch/BytecodePatch {
|
||||
public static final field INSTANCE Lapp/revanced/patches/youtube/interaction/downloads/ExternalDownloadsBytecodePatch;
|
||||
public final class app/revanced/patches/youtube/interaction/downloads/DownloadsPatch : app/revanced/patcher/patch/BytecodePatch {
|
||||
public static final field INSTANCE Lapp/revanced/patches/youtube/interaction/downloads/DownloadsPatch;
|
||||
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
|
||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ object CopyVideoUrlBytecodePatch : BytecodePatch(emptySet()) {
|
||||
)
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
// Initialize buttons and inject visibility control
|
||||
BUTTONS_DESCRIPTORS.forEach { descriptor ->
|
||||
PlayerControlsBytecodePatch.initializeControl("$descriptor->initializeButton(Landroid/view/View;)V")
|
||||
PlayerControlsBytecodePatch.injectVisibilityCheckCall("$descriptor->changeVisibility(Z)V")
|
||||
|
@ -0,0 +1,67 @@
|
||||
package app.revanced.patches.youtube.interaction.downloads
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.interaction.downloads.fingerprints.DownloadButtonActionFingerprint
|
||||
import app.revanced.patches.youtube.misc.playercontrols.PlayerControlsBytecodePatch
|
||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||
import app.revanced.util.exception
|
||||
|
||||
@Patch(
|
||||
name = "Downloads",
|
||||
description = "Adds support to download videos with an external downloader app" +
|
||||
"using the in-app download button or a video player action button.",
|
||||
dependencies = [
|
||||
DownloadsResourcePatch::class,
|
||||
PlayerControlsBytecodePatch::class,
|
||||
VideoInformationPatch::class,
|
||||
],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.youtube",
|
||||
[
|
||||
"18.48.39",
|
||||
"18.49.37",
|
||||
"19.01.34",
|
||||
"19.02.39",
|
||||
"19.03.35",
|
||||
"19.03.36",
|
||||
"19.04.37",
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
@Suppress("unused")
|
||||
object DownloadsPatch : BytecodePatch(
|
||||
setOf(
|
||||
DownloadButtonActionFingerprint,
|
||||
),
|
||||
) {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/DownloadsPatch;"
|
||||
private const val BUTTON_DESCRIPTOR = "Lapp/revanced/integrations/youtube/videoplayer/ExternalDownloadButton;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
PlayerControlsBytecodePatch.initializeControl("$BUTTON_DESCRIPTOR->initializeButton(Landroid/view/View;)V")
|
||||
PlayerControlsBytecodePatch.injectVisibilityCheckCall("$BUTTON_DESCRIPTOR->changeVisibility(Z)V")
|
||||
|
||||
DownloadButtonActionFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
addInstructionsWithLabels(
|
||||
2,
|
||||
"""
|
||||
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->inAppDownloadButtonOnClick()Z
|
||||
move-result v0
|
||||
if-eqz v0, :show_dialog
|
||||
return-void
|
||||
""",
|
||||
ExternalLabel("show_dialog", getInstruction(2)),
|
||||
)
|
||||
}
|
||||
} ?: throw DownloadButtonActionFingerprint.exception
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ import app.revanced.util.copyResources
|
||||
AddResourcesPatch::class,
|
||||
],
|
||||
)
|
||||
internal object ExternalDownloadsResourcePatch : ResourcePatch() {
|
||||
internal object DownloadsResourcePatch : ResourcePatch() {
|
||||
override fun execute(context: ResourceContext) {
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
@ -32,6 +32,7 @@ internal object ExternalDownloadsResourcePatch : ResourcePatch() {
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_external_downloader"),
|
||||
TextPreference("revanced_external_downloader_name", inputType = InputType.TEXT),
|
||||
SwitchPreference("revanced_use_in_app_download_button"),
|
||||
),
|
||||
),
|
||||
)
|
@ -1,54 +0,0 @@
|
||||
package app.revanced.patches.youtube.interaction.downloads
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.misc.playercontrols.PlayerControlsBytecodePatch
|
||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||
|
||||
@Patch(
|
||||
name = "External downloads",
|
||||
description = "Adds support to download and save YouTube videos using an external downloader app.",
|
||||
dependencies = [
|
||||
ExternalDownloadsResourcePatch::class,
|
||||
PlayerControlsBytecodePatch::class,
|
||||
VideoInformationPatch::class,
|
||||
],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.youtube",
|
||||
[
|
||||
"18.48.39",
|
||||
"18.49.37",
|
||||
"19.01.34",
|
||||
"19.02.39",
|
||||
"19.03.35",
|
||||
"19.03.36",
|
||||
"19.04.37",
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
@Suppress("unused")
|
||||
object ExternalDownloadsBytecodePatch : BytecodePatch(emptySet()) {
|
||||
private const val BUTTON_DESCRIPTOR = "Lapp/revanced/integrations/youtube/videoplayer/ExternalDownloadButton;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
/*
|
||||
initialize the control
|
||||
*/
|
||||
|
||||
PlayerControlsBytecodePatch.initializeControl(
|
||||
"$BUTTON_DESCRIPTOR->initializeButton(Landroid/view/View;)V",
|
||||
)
|
||||
|
||||
/*
|
||||
add code to change the visibility of the control
|
||||
*/
|
||||
|
||||
PlayerControlsBytecodePatch.injectVisibilityCheckCall(
|
||||
"$BUTTON_DESCRIPTOR->changeVisibility(Z)V",
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package app.revanced.patches.youtube.interaction.downloads.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
|
||||
internal object DownloadButtonActionFingerprint : MethodFingerprint(
|
||||
strings = listOf("offline/get_download_action"),
|
||||
)
|
@ -226,7 +226,7 @@
|
||||
<string name="revanced_remove_viewer_discretion_dialog_summary_off">Dialog will be shown</string>
|
||||
<string name="revanced_remove_viewer_discretion_dialog_user_dialog_message">This does not bypass the age restriction. It just accepts it automatically.</string>
|
||||
</patch>
|
||||
<patch id="interaction.downloads.ExternalDownloadsResourcePatch">
|
||||
<patch id="interaction.downloads.DownloadsResourcePatch">
|
||||
<string name="revanced_external_downloader_screen_title">External downloads</string>
|
||||
<string name="revanced_external_downloader_screen_summary">Settings for using an external downloader</string>
|
||||
<string name="revanced_external_downloader_title">Show external download button</string>
|
||||
@ -235,6 +235,9 @@
|
||||
<string name="revanced_external_downloader_name_title">Downloader package name</string>
|
||||
<string name="revanced_external_downloader_name_summary">Package name of your installed external downloader app, such as NewPipe or Seal</string>
|
||||
<string name="revanced_external_downloader_not_installed_warning">%s is not installed. Please install it.</string>
|
||||
<string name="revanced_use_in_app_download_button_title">Use in-app download button</string>
|
||||
<string name="revanced_use_in_app_download_button_summary_on">Button will launch the external downloader</string>
|
||||
<string name="revanced_use_in_app_download_button_summary_off">Button will launch the native in-app downloader</string>
|
||||
</patch>
|
||||
<patch id="interaction.seekbar.DisablePreciseSeekingGesturePatch">
|
||||
<string name="revanced_disable_precise_seeking_gesture_title">Disable precise seeking gesture</string>
|
||||
|
Loading…
Reference in New Issue
Block a user