From 7718be3c9af0f50e276fcad6366d41a5f1310cd0 Mon Sep 17 00:00:00 2001 From: Fioren <102145692+FiorenMas@users.noreply.github.com> Date: Sat, 12 Oct 2024 02:00:20 +0700 Subject: [PATCH] Support revanced cli version 5 syntax --- src/build/utils.sh | 69 ++++++++++++------- .../bilibili-BiliRoamingX/exclude-patches | 1 - .../bilibili-BiliRoamingX/include-patches | 1 - src/patches/facebook/exclude-patches | 1 - src/patches/facebook/include-patches | 1 - src/patches/gg-photos/exclude-patches | 1 - src/patches/gg-photos/include-patches | 1 - src/patches/instagram/exclude-patches | 1 - src/patches/instagram/include-patches | 1 - src/patches/lightroom/exclude-patches | 1 - src/patches/lightroom/include-patches | 1 - src/patches/messenger/include-patches | 1 - .../nova-launcher-indrastorms/exclude-patches | 1 - .../nova-launcher-indrastorms/include-patches | 1 - src/patches/pixiv/exclude-patches | 1 - src/patches/pixiv/include-patches | 1 - src/patches/rar/exclude-patches | 1 - src/patches/rar/include-patches | 1 - src/patches/reddit-anddea/exclude-patches | 1 - src/patches/reddit-anddea/include-patches | 1 - src/patches/reddit-rve/exclude-patches | 1 - src/patches/reddit-rve/include-patches | 1 - src/patches/reddit/exclude-patches | 1 - src/patches/reddit/include-patches | 1 - .../tasker-indrastorms/exclude-patches | 1 - .../tasker-indrastorms/include-patches | 1 - src/patches/tiktok/exclude-patches | 1 - src/patches/tiktok/include-patches | 1 - src/patches/tumblr/exclude-patches | 1 - src/patches/tumblr/include-patches | 1 - src/patches/twitch/exclude-patches | 1 - src/patches/twitch/include-patches | 1 - src/patches/twitter/exclude-patches | 1 - src/patches/twitter/include-patches | 1 - src/patches/youtube-ReX/include-patches | 1 - src/patches/youtube-music-ReX/include-patches | 1 - .../youtube-music-revanced/include-patches | 1 - .../youtube-music-rve-anddea/include-patches | 1 - .../youtube-rve-rufusin/exclude-patches | 16 ----- .../youtube-rve-rufusin/include-patches | 1 - 40 files changed, 43 insertions(+), 80 deletions(-) diff --git a/src/build/utils.sh b/src/build/utils.sh index c51c51b..9346e0d 100644 --- a/src/build/utils.sh +++ b/src/build/utils.sh @@ -90,13 +90,39 @@ dl_gh() { get_patches_key() { excludePatches="" includePatches="" - while IFS= read -r line1; do - excludePatches+=" -e \"$line1\"" - done < src/patches/$1/exclude-patches + excludeLinesFound=false + includeLinesFound=false + if [[ $(ls revanced-cli-*.jar) =~ revanced-cli-([0-9]+) ]]; then + num=${BASH_REMATCH[1]} + if [ $num -ge 5 ]; then + while IFS= read -r line1; do + excludePatches+=" -d \"$line1\"" + excludeLinesFound=true + done < src/patches/$1/exclude-patches + + while IFS= read -r line2; do + includePatches+=" -e \"$line2\"" + includeLinesFound=true + done < src/patches/$1/include-patches + else + while IFS= read -r line1; do + excludePatches+=" -e \"$line1\"" + excludeLinesFound=true + done < src/patches/$1/exclude-patches + + while IFS= read -r line2; do + includePatches+=" -i \"$line2\"" + includeLinesFound=true + done < src/patches/$1/include-patches + fi + fi + if [ "$excludeLinesFound" = false ]; then + excludePatches="" + fi + if [ "$includeLinesFound" = false ]; then + includePatches="" + fi export excludePatches - while IFS= read -r line2; do - includePatches+=" -i \"$line2\"" - done < src/patches/$1/include-patches export includePatches } @@ -117,11 +143,8 @@ req() { dl_apk() { local url=$1 regexp=$2 output=$3 url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n "s/href=\"/@/g; s;.*${regexp}.*;\1;p")" - sleep 5 url=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href ".downloadButton") - sleep 5 url=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "span > a[rel = nofollow]") - sleep 5 req "$url" "$output" } get_apk() { @@ -188,35 +211,29 @@ get_apk() { patch() { green_log "[+] Patching $1:" if [ -f "./download/$1.apk" ]; then - local p b m ks a pu + local p b m ks a pu opt if [ "$3" = inotia ]; then - p="patch " b="--patch-bundle" m="--merge" a="" ks="_ks" pu="--purge=true" + p="patch " b="--patch-bundle *patch*.jar" m="--merge *integration*.apk " a="" ks="_ks" pu="--purge=true" opt="--options=./src/options/$2.json " echo "Patching with Revanced-cli inotia" else if [[ $(ls revanced-cli-*.jar) =~ revanced-cli-([0-9]+) ]]; then num=${BASH_REMATCH[1]} - if [ $num -ge 4 ]; then - p="patch " b="--patch-bundle" m="--merge" a="" ks="ks" pu="--purge=true" - echo "Patching with Revanced-cli version 4+" + if [ $num -ge 5 ]; then + p="patch " b="-p *.rvp" m="" a="" ks="ks" pu="--purge=true" opt="" + echo "Patching with Revanced-cli version 5+" + elif [ $num -eq 4 ]; then + p="patch " b="--patch-bundle *patch*.jar" m="--merge *integration*.apk " a="" ks="ks" pu="--purge=true" opt="--options=./src/options/$2.json " + echo "Patching with Revanced-cli version 4" elif [ $num -eq 3 ]; then - p="patch " b="--patch-bundle" m="--merge" a="" ks="_ks" pu="--purge=true" + p="patch " b="--patch-bundle *patch*.jar" m="--merge *integration*.apk " a="" ks="_ks" pu="--purge=true" opt="--options=./src/options/$2.json " echo "Patching with Revanced-cli version 3" elif [ $num -eq 2 ]; then - p="" b="--bundle" m="--merge" a="--apk " ks="_ks" pu="--clean" + p="" b="--bundle *patch*.jar" m="--merge *integration*.apk " a="--apk " ks="_ks" pu="--clean" opt="--options=./src/options/$2.json " echo "Patching with Revanced-cli version 2" fi fi fi - eval java -jar *cli*.jar $p\ - $b *patch*.jar \ - $m *integration*.apk\ - $excludePatches\ - $includePatches \ - --options=./src/options/$2.json \ - --out=./release/$1-$2.apk \ - --keystore=./src/$ks.keystore \ - $pu \ - $a./download/$1.apk + eval java -jar *cli*.jar $p$b $m$opt--out=./release/$1-$2.apk$excludePatches$includePatches --keystore=./src/$ks.keystore $pu $a./download/$1.apk unset version unset excludePatches unset includePatches diff --git a/src/patches/bilibili-BiliRoamingX/exclude-patches b/src/patches/bilibili-BiliRoamingX/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/bilibili-BiliRoamingX/exclude-patches +++ b/src/patches/bilibili-BiliRoamingX/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/bilibili-BiliRoamingX/include-patches b/src/patches/bilibili-BiliRoamingX/include-patches index 8b13789..e69de29 100644 --- a/src/patches/bilibili-BiliRoamingX/include-patches +++ b/src/patches/bilibili-BiliRoamingX/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/facebook/exclude-patches b/src/patches/facebook/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/facebook/exclude-patches +++ b/src/patches/facebook/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/facebook/include-patches b/src/patches/facebook/include-patches index 8b13789..e69de29 100644 --- a/src/patches/facebook/include-patches +++ b/src/patches/facebook/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/gg-photos/exclude-patches b/src/patches/gg-photos/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/gg-photos/exclude-patches +++ b/src/patches/gg-photos/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/gg-photos/include-patches b/src/patches/gg-photos/include-patches index 8b13789..e69de29 100644 --- a/src/patches/gg-photos/include-patches +++ b/src/patches/gg-photos/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/instagram/exclude-patches b/src/patches/instagram/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/instagram/exclude-patches +++ b/src/patches/instagram/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/instagram/include-patches b/src/patches/instagram/include-patches index 8b13789..e69de29 100644 --- a/src/patches/instagram/include-patches +++ b/src/patches/instagram/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/lightroom/exclude-patches b/src/patches/lightroom/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/lightroom/exclude-patches +++ b/src/patches/lightroom/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/lightroom/include-patches b/src/patches/lightroom/include-patches index 8b13789..e69de29 100644 --- a/src/patches/lightroom/include-patches +++ b/src/patches/lightroom/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/messenger/include-patches b/src/patches/messenger/include-patches index 8b13789..e69de29 100644 --- a/src/patches/messenger/include-patches +++ b/src/patches/messenger/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/nova-launcher-indrastorms/exclude-patches b/src/patches/nova-launcher-indrastorms/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/nova-launcher-indrastorms/exclude-patches +++ b/src/patches/nova-launcher-indrastorms/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/nova-launcher-indrastorms/include-patches b/src/patches/nova-launcher-indrastorms/include-patches index 8b13789..e69de29 100644 --- a/src/patches/nova-launcher-indrastorms/include-patches +++ b/src/patches/nova-launcher-indrastorms/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/pixiv/exclude-patches b/src/patches/pixiv/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/pixiv/exclude-patches +++ b/src/patches/pixiv/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/pixiv/include-patches b/src/patches/pixiv/include-patches index 8b13789..e69de29 100644 --- a/src/patches/pixiv/include-patches +++ b/src/patches/pixiv/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/rar/exclude-patches b/src/patches/rar/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/rar/exclude-patches +++ b/src/patches/rar/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/rar/include-patches b/src/patches/rar/include-patches index 8b13789..e69de29 100644 --- a/src/patches/rar/include-patches +++ b/src/patches/rar/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/reddit-anddea/exclude-patches b/src/patches/reddit-anddea/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/reddit-anddea/exclude-patches +++ b/src/patches/reddit-anddea/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/reddit-anddea/include-patches b/src/patches/reddit-anddea/include-patches index 8b13789..e69de29 100644 --- a/src/patches/reddit-anddea/include-patches +++ b/src/patches/reddit-anddea/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/reddit-rve/exclude-patches b/src/patches/reddit-rve/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/reddit-rve/exclude-patches +++ b/src/patches/reddit-rve/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/reddit-rve/include-patches b/src/patches/reddit-rve/include-patches index 8b13789..e69de29 100644 --- a/src/patches/reddit-rve/include-patches +++ b/src/patches/reddit-rve/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/reddit/exclude-patches b/src/patches/reddit/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/reddit/exclude-patches +++ b/src/patches/reddit/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/reddit/include-patches b/src/patches/reddit/include-patches index 8b13789..e69de29 100644 --- a/src/patches/reddit/include-patches +++ b/src/patches/reddit/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/tasker-indrastorms/exclude-patches b/src/patches/tasker-indrastorms/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/tasker-indrastorms/exclude-patches +++ b/src/patches/tasker-indrastorms/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/tasker-indrastorms/include-patches b/src/patches/tasker-indrastorms/include-patches index 8b13789..e69de29 100644 --- a/src/patches/tasker-indrastorms/include-patches +++ b/src/patches/tasker-indrastorms/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/tiktok/exclude-patches b/src/patches/tiktok/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/tiktok/exclude-patches +++ b/src/patches/tiktok/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/tiktok/include-patches b/src/patches/tiktok/include-patches index 8b13789..e69de29 100644 --- a/src/patches/tiktok/include-patches +++ b/src/patches/tiktok/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/tumblr/exclude-patches b/src/patches/tumblr/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/tumblr/exclude-patches +++ b/src/patches/tumblr/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/tumblr/include-patches b/src/patches/tumblr/include-patches index 8b13789..e69de29 100644 --- a/src/patches/tumblr/include-patches +++ b/src/patches/tumblr/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/twitch/exclude-patches b/src/patches/twitch/exclude-patches index 67ab619..e69de29 100644 --- a/src/patches/twitch/exclude-patches +++ b/src/patches/twitch/exclude-patches @@ -1 +0,0 @@ -debug-mode diff --git a/src/patches/twitch/include-patches b/src/patches/twitch/include-patches index 8b13789..e69de29 100644 --- a/src/patches/twitch/include-patches +++ b/src/patches/twitch/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/twitter/exclude-patches b/src/patches/twitter/exclude-patches index 8b13789..e69de29 100644 --- a/src/patches/twitter/exclude-patches +++ b/src/patches/twitter/exclude-patches @@ -1 +0,0 @@ - diff --git a/src/patches/twitter/include-patches b/src/patches/twitter/include-patches index 8b13789..e69de29 100644 --- a/src/patches/twitter/include-patches +++ b/src/patches/twitter/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/youtube-ReX/include-patches b/src/patches/youtube-ReX/include-patches index 8b13789..e69de29 100644 --- a/src/patches/youtube-ReX/include-patches +++ b/src/patches/youtube-ReX/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/youtube-music-ReX/include-patches b/src/patches/youtube-music-ReX/include-patches index 8b13789..e69de29 100644 --- a/src/patches/youtube-music-ReX/include-patches +++ b/src/patches/youtube-music-ReX/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/youtube-music-revanced/include-patches b/src/patches/youtube-music-revanced/include-patches index 8b13789..e69de29 100644 --- a/src/patches/youtube-music-revanced/include-patches +++ b/src/patches/youtube-music-revanced/include-patches @@ -1 +0,0 @@ - diff --git a/src/patches/youtube-music-rve-anddea/include-patches b/src/patches/youtube-music-rve-anddea/include-patches index f59231f..e69de29 100644 --- a/src/patches/youtube-music-rve-anddea/include-patches +++ b/src/patches/youtube-music-rve-anddea/include-patches @@ -1 +0,0 @@ -Custom branding name for YouTube Music diff --git a/src/patches/youtube-rve-rufusin/exclude-patches b/src/patches/youtube-rve-rufusin/exclude-patches index 893145f..2ef084c 100644 --- a/src/patches/youtube-rve-rufusin/exclude-patches +++ b/src/patches/youtube-rve-rufusin/exclude-patches @@ -1,18 +1,2 @@ Custom branding icon YouTube -Enable compact controls overlay -Disable QUIC protocol -Disable auto captions -Disable HDR video -Enable zen mode -Hide account menu -Hide autoplay button -Hide autoplay preview -Hide captions button -Hide description components -Hide handle -Hide latest videos button -Hide load more button -Hide mix playlists -Hide previous next button -Custom seekbar color Translations diff --git a/src/patches/youtube-rve-rufusin/include-patches b/src/patches/youtube-rve-rufusin/include-patches index 8b13789..e69de29 100644 --- a/src/patches/youtube-rve-rufusin/include-patches +++ b/src/patches/youtube-rve-rufusin/include-patches @@ -1 +0,0 @@ -