update dl func

This commit is contained in:
Fioren
2024-12-27 00:06:09 +07:00
committed by GitHub
parent e5d7dee76b
commit 9b181e15fd

View File

@@ -3,9 +3,9 @@
mkdir ./release ./download mkdir ./release ./download
#Setup pup for download apk files #Setup pup for download apk files
#wget -q -O ./pup.zip https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip wget -q -O ./pup.zip https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip
#unzip "./pup.zip" -d "./" > /dev/null 2>&1 unzip "./pup.zip" -d "./" > /dev/null 2>&1
#pup="./pup" pup="./pup"
#Setup APKEditor for install combine split apks #Setup APKEditor for install combine split apks
wget -q -O ./APKEditor.jar https://github.com/REAndroid/APKEditor/releases/download/V1.4.1/APKEditor-1.4.1.jar wget -q -O ./APKEditor.jar https://github.com/REAndroid/APKEditor/releases/download/V1.4.1/APKEditor-1.4.1.jar
APKEditor="./APKEditor.jar" APKEditor="./APKEditor.jar"
@@ -214,16 +214,13 @@ get_apk() {
local attempt=0 local attempt=0
while [ $attempt -lt 10 ]; do while [ $attempt -lt 10 ]; do
if [[ -z $version ]] || [ $attempt -ne 0 ]; then if [[ -z $version ]] || [ $attempt -ne 0 ]; then
local list_vers v _versions=() IFS=$'\n' version=$(req "https://www.apkmirror.com/uploads/?appcategory=$3" - | \
list_vers=$(req "https://www.apkmirror.com/uploads/?appcategory=$3" -) $pup 'div.widget_appmanager_recentpostswidget h5 a.fontBlack text{}' | \
version=$(sed -n 's;.*Version:</span><span class="infoSlide-value">\(.*\) </span>.*;\1;p' <<<"$list_vers") grep -Evi 'alpha|beta' | \
version=$(grep -iv "\(beta\|alpha\)" <<<"$version") grep -oPi '\b\d+(\.\d+)+(?:\-\w+)?(?:\.\d+)?(?:\.\w+)?\b' | \
for v in $version; do sed -n "$((attempt + 1))p")
grep -iq "${v} \(beta\|alpha\)" <<<"$list_vers" || _versions+=("$v")
done
version=$(echo -e "${_versions[*]}" | sed -n "$((attempt + 1))p")
fi fi
version=$(echo "$version" | tr -d ' ' | sed 's/\./-/g') version=$(echo "$version" | tr -d ' ' | sed 's/\./-/g')
green_log "[+] Downloading $3 version: $version $5 $6 $7" green_log "[+] Downloading $3 version: $version $5 $6 $7"
if [[ $5 == "Bundle" ]] || [[ $5 == "Bundle_extract" ]]; then if [[ $5 == "Bundle" ]] || [[ $5 == "Bundle_extract" ]]; then
local base_apk="$2.apkm" local base_apk="$2.apkm"
@@ -240,9 +237,10 @@ get_apk() {
else else
((attempt++)) ((attempt++))
red_log "[-] Failed to download $2, trying another version" red_log "[-] Failed to download $2, trying another version"
unset version list_vers v versions unset version
fi fi
done done
if [ $attempt -eq 10 ]; then if [ $attempt -eq 10 ]; then
red_log "[-] No more versions to try. Failed download" red_log "[-] No more versions to try. Failed download"
return 1 return 1
@@ -354,4 +352,4 @@ split_arch() {
red_log "[-] Not found $1.apk" red_log "[-] Not found $1.apk"
exit 1 exit 1
fi fi
} }