Auto detect compatible version

This commit is contained in:
Sayantan Santra 2022-10-09 21:33:06 -05:00
parent 2b1002e40d
commit efe0ca6d2f
3 changed files with 14 additions and 8 deletions

2
build_revanced.sh Executable file → Normal file
View file

@ -49,7 +49,7 @@ populate_patches() {
# cleanup to fetch new revanced on next run # cleanup to fetch new revanced on next run
if [[ "$1" == "clean" ]]; then if [[ "$1" == "clean" ]]; then
rm -f revanced-cli.jar revanced-integrations.apk revanced-patches.jar rm -f revanced-cli.jar revanced-integrations.apk revanced-patches.jar patches.json
exit exit
fi fi

View file

@ -2,8 +2,8 @@
declare -A apks declare -A apks
apks["com.google.android.youtube.apk"]=dl_yt apks["com.google.android.youtube"]=dl_yt
apks["com.google.android.apps.youtube.music.apk"]=dl_ytm apks["com.google.android.apps.youtube.music"]=dl_ytm
## Functions ## Functions
@ -86,7 +86,17 @@ dl_ytm() {
for apk in "${!apks[@]}"; do for apk in "${!apks[@]}"; do
if [ ! -f $apk ]; then if [ ! -f $apk ]; then
echo "Downloading $apk" echo "Downloading $apk"
version=$(jq -r ".\"$apk\"" <versions.json) [ ! -f patches.json ] && req "https://raw.githubusercontent.com/revanced/revanced-patches/main/patches.json" patches.json
supported_vers="$(jq -r '.[].compatiblePackages[] | select(.name == "'$apk'") | .versions | last' patches.json)"
version=0
for vers in $supported_vers; do
if [ $vers != "null" ]; then
if [[ ${vers//[!0-9]/} -gt ${version//[!0-9]/} ]]; then
version=$vers
fi
fi
done
# version=$(jq -r ".\"$apk\"" <versions.json)
${apks[$apk]} ${apks[$apk]}
fi fi
done done

View file

@ -1,4 +0,0 @@
{
"com.google.android.youtube.apk": "17.36.37",
"com.google.android.apps.youtube.music.apk": "5.26.52"
}