Update patch.sh

This commit is contained in:
FiorenMas
2023-04-11 23:09:52 +07:00
committed by GitHub
parent 8a1a13a2ee
commit 2af3e59705

View File

@@ -1,15 +1,15 @@
#!/bin/bash `#!/bin/bash
set -e set -e
# Set variables for Revanced # Set variables for Revanced
readonly revanced_name="revanced" readonly revanced_name="revanced"
readonly revanced_user="revanced" readonly revanced_user="revanced"
readonly revanced_patch="patches.rv" readonly revanced_patch="patches.rv"
readonly revanced_ytversion="" # Input version supported if you need patch specific YT version.Example: "18.03.36" readonly revanced_ytmsversion="" # Input version supported if you need patch specific YT version.Example: "18.03.36"
# Set variables for Revanced Extended # Set variables for Revanced Extended
readonly revanced_extended_name="revanced-extended" readonly revanced_extended_name="revanced-extended"
readonly revanced_extended_user="inotia00" readonly revanced_extended_user="inotia00"
readonly revanced_extended_patch="patches.rve" readonly revanced_extended_patch="patches.rve"
readonly revanced_extended_ytversion="" # Input version supported if you need patch specific YT version.Example: "18.07.35" readonly revanced_extended_ytmsversion="" # Input version supported if you need patch specific YT version.Example: "18.07.35"
# Function prepare patches keywords # Function prepare patches keywords
get_patch() { get_patch() {
local excluded_start=$(grep -n -m1 'EXCLUDE PATCHES' "$patch_file" | cut -d':' -f1) local excluded_start=$(grep -n -m1 'EXCLUDE PATCHES' "$patch_file" | cut -d':' -f1)
@@ -40,14 +40,22 @@ download_latest_release() {
req() { req() {
curl -sSL -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:111.0) Gecko/20100101 Firefox/111.0" "$1" -o "$2" curl -sSL -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:111.0) Gecko/20100101 Firefox/111.0" "$1" -o "$2"
} }
dl_yt() { dl_ytm() {
rm -rf $2 rm -rf $2
echo "Downloading YouTube $1..." echo "Downloading YouTubeMusic $1"
url="https://www.apkmirror.com/apk/google-inc/youtube/youtube-${1//./-}-release/" url="https://www.apkmirror.com/apk/google-inc/youtube/youtube-music-${1//./-}-release/"
url="$url$(req "$url" - | grep Variant -A50 | grep ">APK<" -A2 | grep android-apk-download | sed "s#.*-release/##g;s#/\#.*##g")" url="$url$(req "$url" - | grep arm64 -A30 | grep youtube-music | head -1 | sed "s#.*-release/##g;s#/\".*##g")"
url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')" url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')"
url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')" url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')"
req "$url" "$2" req "$url" "$2"
}
get_latestytmversion() {
url="https://www.apkmirror.com/apk/google-inc/youtube-music/"
ytmsversion=$(req "$url" - | grep "All version" -A200 | grep app_release | sed 's:.*/youtube-music-::g;s:-release/.*::g;s:-:.:g' | sort -r | head -1)
echo "Latest YoutubeMusic Version: $ytmsversion"
}
get_support_version() {
ytmsversion=$(jq -r '.[] | select(.name == "hide-get-premium") | .compatiblePackages[] | select(.name == "com.google.android.apps.youtube.music") | .versions[-1]' patches.json)
} }
# Function Patch APK # Function Patch APK
patch_apk() { patch_apk() {
@@ -55,10 +63,10 @@ echo "⚙️ Patching YouTube..."
java -jar revanced-cli*.jar \ java -jar revanced-cli*.jar \
-m revanced-integrations*.apk \ -m revanced-integrations*.apk \
-b revanced-patches*.jar \ -b revanced-patches*.jar \
-a youtube-v$ytversion.apk \ -a youtube-music-v$ytmsversion.apk \
${patches[@]} \ ${patches[@]} \
--keystore=ks.keystore \ --keystore=ks.keystore \
-o yt-$name.apk -o ytms-$name-v$ytmsversion.apk
} }
# Function clean caches to new build # Function clean caches to new build
clean_cache() { clean_cache() {
@@ -76,19 +84,20 @@ for name in $revanced_name $revanced_extended_name ; do
if [[ "$name" = "$revanced_name" ]]; then if [[ "$name" = "$revanced_name" ]]; then
user="$revanced_user" user="$revanced_user"
patch_file="$revanced_patch" patch_file="$revanced_patch"
ytversion="$revanced_ytversion" ytmsversion="$revanced_ytmsversion"
else else
user="$revanced_extended_user" user="$revanced_extended_user"
patch_file="$revanced_extended_patch" patch_file="$revanced_extended_patch"
ytversion="$revanced_extended_ytversion" ytmsversion="$revanced_extended_ytmsversion"
fi fi
get_patch get_patch
download_latest_release download_latest_release
if [[ $ytversion ]] ; if [[ "$name" = "$revanced_name" ]] ; then
then dl_yt $ytversion youtube-v$ytversion.apk get_support_version
else ytversion=$(jq -r '.[] | select(.name == "microg-support") | .compatiblePackages[] | select(.name == "com.google.android.youtube") | .versions[-1]' patches.json) dl_ytm $ytmsversion youtube-music-v$ytmsversion.apk
dl_yt $ytversion youtube-v$ytversion.apk else get_latestytmversion
fi dl_ytm $ytmsversion youtube-music-v$ytmsversion.apk
fi
patch_apk patch_apk
clean_cache clean_cache
done done`