generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube - External downloader): Add ability to use in-app downlo…
…ad button
- Loading branch information
Showing
7 changed files
with
82 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
...tlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsBytecodePatch.kt
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...ced/patches/youtube/interaction/downloads/fingerprints/DownloadButtonActionFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d900011
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want the same features in yt music
d900011
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hassan1395 you are welcome to develop a similar patch for YT Music and create a pull request with the changes