mirror of
https://github.com/FiorenMas/Revanced-And-Revanced-Extended-Non-Root.git
synced 2025-12-06 16:17:40 +00:00
Update patch.sh
This commit is contained in:
100
patch.sh
100
patch.sh
@@ -1,77 +1,57 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Input *ytversion number/blank(or # before) to set specific/auto choose YouTube version
|
set -e
|
||||||
|
|
||||||
# Set variables for Revanced
|
# Set variables for Revanced
|
||||||
revanced_name="revanced"
|
readonly revanced_name="revanced"
|
||||||
revanced_user="revanced"
|
readonly revanced_user="revanced"
|
||||||
revanced_patch="patches.rv"
|
readonly revanced_patch="patches.rv"
|
||||||
revanced_ytversion="" # Input version supported.Exp: 18.03.36
|
readonly revanced_ytversion="" # Input version supported if you need patch specific YT version.Example: "18.03.36"
|
||||||
|
|
||||||
# Set variables for Revanced Extended
|
# Set variables for Revanced Extended
|
||||||
revanced_extended_name="revanced-extended"
|
readonly revanced_extended_name="revanced-extended"
|
||||||
revanced_extended_user="inotia00"
|
readonly revanced_extended_user="inotia00"
|
||||||
revanced_extended_patch="patches.rve"
|
readonly revanced_extended_patch="patches.rve"
|
||||||
revanced_extended_ytversion="" # Input version supported.Exp: 18.07.35
|
readonly revanced_extended_ytversion="" # 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() {
|
||||||
excluded_start=$(grep -n -m1 'EXCLUDE PATCHES' "$patch_file" \
|
local excluded_start=$(grep -n -m1 'EXCLUDE PATCHES' "$patch_file" | cut -d':' -f1)
|
||||||
| cut -d':' -f1)
|
local included_start=$(grep -n -m1 'INCLUDE PATCHES' "$patch_file" | cut -d':' -f1)
|
||||||
included_start=$(grep -n -m1 'INCLUDE PATCHES' "$patch_file" \
|
local excluded_patches=$(tail -n +$excluded_start $patch_file | head -n "$(( included_start - excluded_start ))" | grep '^[^#[:blank:]]')
|
||||||
| cut -d':' -f1)
|
local included_patches=$(tail -n +$included_start $patch_file | grep '^[^#[:blank:]]')
|
||||||
excluded_patches=$(tail -n +$excluded_start $patch_file \
|
local patches=()
|
||||||
| head -n "$(( included_start - excluded_start ))" \
|
if [[ -n "$excluded_patches" ]]; then
|
||||||
| grep '^[^#[:blank:]]')
|
|
||||||
included_patches=$(tail -n +$included_start $patch_file \
|
|
||||||
| grep '^[^#[:blank:]]')
|
|
||||||
patches=()
|
|
||||||
if [ -n "$excluded_patches" ]; then
|
|
||||||
while read -r patch; do
|
while read -r patch; do
|
||||||
patches+=("-e $patch")
|
patches+=("-e $patch")
|
||||||
done <<< "$excluded_patches"
|
done <<< "$excluded_patches"
|
||||||
fi
|
fi
|
||||||
if [ -n "$included_patches" ]; then
|
if [[ -n "$included_patches" ]]; then
|
||||||
while read -r patch; do
|
while read -r patch; do
|
||||||
patches+=("-i $patch")
|
patches+=("-i $patch")
|
||||||
done <<< "$included_patches"
|
done <<< "$included_patches"
|
||||||
fi
|
fi
|
||||||
declare -a patches
|
|
||||||
}
|
}
|
||||||
# Function download latest github releases
|
# Function download latest github releases
|
||||||
urls_res() {
|
download_latest_release() {
|
||||||
wget -q -O - "https://api.github.com/repos/$user/revanced-patches/releases/latest" \
|
echo "⏬ Downloading $name resources..."
|
||||||
| jq -r '.assets[].browser_download_url'
|
for repos in revanced-patches revanced-cli revanced-integrations; do
|
||||||
wget -q -O - "https://api.github.com/repos/$user/revanced-cli/releases/latest" \
|
local url="https://api.github.com/repos/$user/$repos/releases/latest"
|
||||||
| jq -r '.assets[].browser_download_url'
|
curl -s "$url" | jq -r '.assets[].browser_download_url' | xargs -n 1 curl -O -s -L
|
||||||
wget -q -O - "https://api.github.com/repos/$user/revanced-integrations/releases/latest" \
|
done
|
||||||
| jq -r '.assets[].browser_download_url'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function download YouTube apk from APKmirror
|
# Function download YouTube apk from APKmirror
|
||||||
WGET_HEADER="User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:111.0) Gecko/20100101 Firefox/111.0"
|
|
||||||
|
|
||||||
req() {
|
req() {
|
||||||
wget -q -O "$2" --header="$WGET_HEADER" "$1"
|
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_yt() {
|
||||||
rm -rf $2
|
rm -rf $2
|
||||||
url="https://www.apkmirror.com/apk/google-inc/youtube/youtube-${1//./-}-release/"
|
echo "⏬ Downloading YouTube $1..."
|
||||||
url="$url$(req "$url" - \
|
url="https://www.apkmirror.com/apk/google-inc/youtube/youtube-${1//./-}-release/"
|
||||||
| grep Variant -A50 \
|
url="$url$(req "$url" - | grep Variant -A50 | grep ">APK<" -A2 | grep android-apk-download | sed "s#.*-release/##g;s#/\#.*##g")"
|
||||||
| grep ">APK<" -A2 \
|
url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')"
|
||||||
| grep android-apk-download \
|
url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')"
|
||||||
| sed "s#.*-release/##g;s#/\#.*##g")"
|
req "$url" "$2"
|
||||||
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"
|
|
||||||
}
|
}
|
||||||
# Function Patch APK
|
# Function Patch APK
|
||||||
patch_apk() {
|
patch_apk() {
|
||||||
|
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 \
|
||||||
@@ -82,6 +62,7 @@ java -jar revanced-cli*.jar \
|
|||||||
}
|
}
|
||||||
# Function clean caches to new build
|
# Function clean caches to new build
|
||||||
clean_cache() {
|
clean_cache() {
|
||||||
|
echo "🧹 Clean caches..."
|
||||||
rm -f revanced-cli*.jar \
|
rm -f revanced-cli*.jar \
|
||||||
revanced-integrations*.apk \
|
revanced-integrations*.apk \
|
||||||
revanced-patches*.jar \
|
revanced-patches*.jar \
|
||||||
@@ -89,10 +70,10 @@ rm -f revanced-cli*.jar \
|
|||||||
options.toml \
|
options.toml \
|
||||||
youtube*.apk \
|
youtube*.apk \
|
||||||
}
|
}
|
||||||
# Function patch Revanced, Revanced Extended
|
# Loop over Revanced & Revanced Extended
|
||||||
for name in $revanced_name $revanced_extended_name ; do
|
for name in $revanced_name $revanced_extended_name ; do
|
||||||
# Select variables based on name
|
# Select variables based on name
|
||||||
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"
|
ytversion="$revanced_ytversion"
|
||||||
@@ -100,19 +81,14 @@ for name in $revanced_name $revanced_extended_name ; do
|
|||||||
user="$revanced_extended_user"
|
user="$revanced_extended_user"
|
||||||
patch_file="$revanced_extended_patch"
|
patch_file="$revanced_extended_patch"
|
||||||
ytversion="$revanced_extended_ytversion"
|
ytversion="$revanced_extended_ytversion"
|
||||||
fi
|
fi
|
||||||
get_patch
|
get_patch
|
||||||
echo "⏬ Downloading $name resources..."
|
download_latest_release
|
||||||
urls_res | xargs wget -q -i
|
if [[ $ytversion ]] ;
|
||||||
if [ $ytversion ] ;
|
|
||||||
then dl_yt $ytversion youtube-v$ytversion.apk
|
then dl_yt $ytversion youtube-v$ytversion.apk
|
||||||
echo "⏬ Downloading YouTube v$ytversion.."
|
|
||||||
else ytversion=$(jq -r '.[] | select(.name == "microg-support") | .compatiblePackages[] | select(.name == "com.google.android.youtube") | .versions[-1]' patches.json)
|
else ytversion=$(jq -r '.[] | select(.name == "microg-support") | .compatiblePackages[] | select(.name == "com.google.android.youtube") | .versions[-1]' patches.json)
|
||||||
dl_yt $ytversion youtube-v$ytversion.apk
|
dl_yt $ytversion youtube-v$ytversion.apk
|
||||||
echo "⏬ Downloading YouTube v$ytversion..."
|
fi
|
||||||
fi
|
|
||||||
echo "⚙️ Patching YouTube..."
|
|
||||||
patch_apk
|
patch_apk
|
||||||
echo "🧹 Clean caches..."
|
|
||||||
clean_cache
|
clean_cache
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user