fix dl_uptodown again

This commit is contained in:
j-hc 2025-03-31 23:43:55 +03:00
parent a03fd75048
commit 13fecaba58
No known key found for this signature in database
GPG Key ID: CDF97F1DBFE904CD

View File

@ -369,44 +369,44 @@ get_uptodown_resp() {
get_uptodown_vers() { $HTMLQ --text ".version" <<<"$__UPTODOWN_RESP__"; }
dl_uptodown() {
local uptodown_dlurl=$1 version=$2 output=$3 arch=$4 _dpi=$5
local apparch
if [ "$arch" = "arm-v7a" ]; then arch="armeabi-v7a"; fi
if [ "$arch" = all ]; then
apparch=('arm64-v8a, armeabi-v7a, x86, x86_64' 'arm64-v8a, armeabi-v7a')
else apparch=("$arch" 'arm64-v8a, armeabi-v7a, x86, x86_64' 'arm64-v8a, armeabi-v7a'); fi
local op resp data_code
data_code=$($HTMLQ "#detail-app-name" --attribute data-code <<<"$__UPTODOWN_RESP__")
local versionURL=""
local might_be_bundle=false
local is_bundle=false
for i in {1..5}; do
resp=$(req "${uptodown_dlurl}/apps/${data_code}/versions/${i}" -)
if ! op=$(jq -e -r ".data | map(select(.version == \"${version}\")) | .[0]" <<<"$resp"); then
continue
fi
if [ $(jq -e -r ".kindFile" <<<"$op") = "xapk" ]; then might_be_bundle=true; fi
if [ "$(jq -e -r ".kindFile" <<<"$op")" = "xapk" ]; then is_bundle=true; fi
if versionURL=$(jq -e -r '.versionURL' <<<"$op"); then break; else return 1; fi
done
if [ -z "$versionURL" ]; then return 1; fi
resp=$(req "$versionURL" -) || return 1
if [ "$arch" != all ]; then
local data_version files node_arch data_file_id
data_version=$($HTMLQ '.button.variants' --attribute data-version <<<"$resp") || return 1
files=$(req "${uptodown_dlurl%/*}/app/${data_code}/version/${data_version}/files" - | jq -e -r .content) || return 1
for ((n = 1; n < 12; n += 2)); do
node_arch=$($HTMLQ ".content > p:nth-child($n)" --text <<<"$files" | xargs) || return 1
if [ -z "$node_arch" ]; then return 1; fi
if [ "$node_arch" != "$arch" ]; then continue; fi
if ! isoneof "$node_arch" "${apparch[@]}"; then continue; fi
data_file_id=$($HTMLQ "div.variant:nth-child($((n + 1))) > .v-report" --attribute data-file-id <<<"$files") || return 1
resp=$(req "${uptodown_dlurl}/download/${data_file_id}" -)
resp=$(req "${uptodown_dlurl}/download/${data_file_id}-x" -)
break
done
fi
local data_url
data_url=$($HTMLQ "#detail-download-button" --attribute data-url <<<"$resp") || return 1
if [ $might_be_bundle = true ]; then
if [ $is_bundle = true ]; then
req "https://dw.uptodown.com/dwn/${data_url}" "$output.apkm" || return 1
if grep -qF "AndroidManifest.xml" <<<$(unzip -l "$output.apkm"); then
mv -f "${output}.apkm" "${output}"
else
merge_splits "${output}.apkm" "${output}"
fi
else
req "https://dw.uptodown.com/dwn/${data_url}" "$output"
fi