diff --git a/src/build/Revanced-Extended-Android-6-7.sh b/src/build/Revanced-Extended-Android-6-7.sh index 5f75bff..931815e 100644 --- a/src/build/Revanced-Extended-Android-6-7.sh +++ b/src/build/Revanced-Extended-Android-6-7.sh @@ -12,6 +12,7 @@ checker "kitadai31/revanced-patches-android6-7" "revanced-extended-android-6-7" # Download requirement patches dl_gh "revanced-patches-android6-7 revanced-integrations" "kitadai31" "latest" dl_gh "revanced-cli" "inotia00" "latest" +dl_htmlq ################################################# diff --git a/src/build/Revanced-Extended.sh b/src/build/Revanced-Extended.sh index cad8f78..772c15b 100644 --- a/src/build/Revanced-Extended.sh +++ b/src/build/Revanced-Extended.sh @@ -9,8 +9,9 @@ checker "inotia00/revanced-patches" "revanced-extended" ################################################# -# Download requirement patches +# Download requirements dl_gh "revanced-patches revanced-cli revanced-integrations" "inotia00" "latest" +dl_htmlq ################################################# diff --git a/src/build/Revanced.sh b/src/build/Revanced.sh index d402594..c490367 100644 --- a/src/build/Revanced.sh +++ b/src/build/Revanced.sh @@ -11,6 +11,7 @@ checker "revanced/revanced-patches" "revanced" # Download requirement patches dl_gh "revanced-patches revanced-cli revanced-integrations" "revanced" "latest" +dl_htmlq ################################################# diff --git a/src/build/utils.sh b/src/build/utils.sh index e060b61..bbe94b7 100644 --- a/src/build/utils.sh +++ b/src/build/utils.sh @@ -21,6 +21,16 @@ fi ################################################# +# Download the htmlq for to get apk from APKMirror +dl_htmlq() { + req "https://github.com/mgdm/htmlq/releases/latest/download/htmlq-x86_64-linux.tar.gz" "./htmlq.tar.gz" + tar -xf "./htmlq.tar.gz" -C "./" + rm "./htmlq.tar.gz" + HTMLQ="./htmlq" +} + +################################################# + # Download Github assets requirement: dl_gh() { for repo in $1 ; do @@ -64,9 +74,21 @@ get_ver() { ################################################# # Download apks files from APKMirror: -req() { - wget -nv -O "$2" -U "Mozilla/5.0 (X11; Linux x86_64; rv:111.0) Gecko/20100101 Firefox/111.0" "$1" + +_req() { + if [ "$2" = - ]; then + wget -nv -O "$2" --header="$3" "$1" + else + local dlp + dlp="$(dirname "$2")/$(basename "$2")" + if [ -f "$dlp" ]; then + while [ -f "$dlp" ]; do sleep 1; done + return + fi + wget -nv -O "$dlp" --header="$3" "$1" || return 1 + fi } +req() { _req "$1" "$2" "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0"; } get_apk_vers() { req "$1" - | sed -n 's;.*Version:\(.*\) .*;\1;p' @@ -81,11 +103,17 @@ get_largest_ver() { } dl_apk() { - local url=$1 regexp=$2 output=$3 + local url=$1 regexp=$2 output=$3 resp url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n "s/href=\"/@/g; s;.*${regexp}.*;\1;p")" echo "$url" - 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=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "a.accent_bg.btn") + resp=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "span > a[rel = nofollow]") + if [[ -z $resp ]]; then + url=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "a.accent_bg.btn") + url=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "span > a[rel = nofollow]") + else + url=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "span > a[rel = nofollow]") + fi req "$url" "$output" }