diff --git a/utils.sh b/utils.sh index 67fb2b5..fdd3494 100755 --- a/utils.sh +++ b/utils.sh @@ -222,19 +222,23 @@ dl_apkmirror() { else apparch=("$arch" universal noarch 'arm64-v8a + armeabi-v7a'); fi url="${url}/${url##*/}-${version//./-}-release/" resp=$(req "$url" -) || return 1 - for ((n = 1; n < 40; n++)); do - node=$($HTMLQ "div.table-row.headerFont:nth-last-child($n)" -r "span:nth-child(n+3)" <<<"$resp") - if [ -z "$node" ]; then break; fi - app_table=$($HTMLQ --text --ignore-whitespace <<<"$node") - if [ "$(sed -n 3p <<<"$app_table")" = "$apkorbundle" ] && { [ "$apkorbundle" = BUNDLE ] || - { [ "$apkorbundle" = APK ] && [ "$(sed -n 6p <<<"$app_table")" = "$dpi" ] && - isoneof "$(sed -n 4p <<<"$app_table")" "${apparch[@]}"; }; }; then - dlurl=$($HTMLQ --base https://www.apkmirror.com --attribute href "div:nth-child(1) > a:nth-child(1)" <<<"$node") - break - fi - done - [ -z "$dlurl" ] && return 1 - url=$(req "$dlurl" - | $HTMLQ --base https://www.apkmirror.com --attribute href "a.btn") || return 1 + node=$($HTMLQ "div.table-row.headerFont:nth-last-child(1)" -r "span:nth-child(n+3)" <<<"$resp") + if [ "$node" ]; then + for ((n = 1; n < 40; n++)); do + node=$($HTMLQ "div.table-row.headerFont:nth-last-child($n)" -r "span:nth-child(n+3)" <<<"$resp") + if [ -z "$node" ]; then break; fi + app_table=$($HTMLQ --text --ignore-whitespace <<<"$node") + if [ "$(sed -n 3p <<<"$app_table")" = "$apkorbundle" ] && { [ "$apkorbundle" = BUNDLE ] || + { [ "$apkorbundle" = APK ] && [ "$(sed -n 6p <<<"$app_table")" = "$dpi" ] && + isoneof "$(sed -n 4p <<<"$app_table")" "${apparch[@]}"; }; }; then + dlurl=$($HTMLQ --base https://www.apkmirror.com --attribute href "div:nth-child(1) > a:nth-child(1)" <<<"$node") + break + fi + done + [ -z "$dlurl" ] && return 1 + resp=$(req "$dlurl" -) + fi + url=$(echo "$resp" | $HTMLQ --base https://www.apkmirror.com --attribute href "a.btn") || return 1 if [ "$apkorbundle" = BUNDLE ] && [[ "$url" != *"&forcebaseapk=true" ]]; then url="${url}&forcebaseapk=true"; fi url=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "span > a[rel = nofollow]") || return 1 req "$url" "$output"