mirror of
https://github.com/Nezumi-2711/revanced-apk-build.git
synced 2026-09-22 20:02:00 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d24f8939d0 | ||
|
|
3becfad4f7 | ||
|
|
0e85707946 |
@@ -99,7 +99,15 @@ get_rv_prebuilts() {
|
|||||||
resp=$(gh_req "$rv_rel" -) || return 1
|
resp=$(gh_req "$rv_rel" -) || return 1
|
||||||
if [ "$ver" = "dev" ]; then resp=$(jq -r '.[0]' <<<"$resp"); fi
|
if [ "$ver" = "dev" ]; then resp=$(jq -r '.[0]' <<<"$resp"); fi
|
||||||
tag_name=$(jq -r '.tag_name' <<<"$resp")
|
tag_name=$(jq -r '.tag_name' <<<"$resp")
|
||||||
asset=$(jq -e -r ".assets[] | select(.name | endswith(\"$ext\"))" <<<"$resp") || return 1
|
# Filter assets by extension and handle multiple matches
|
||||||
|
# Use jq array syntax to get first match as a complete JSON object
|
||||||
|
if [ "$ver" = "dev" ]; then
|
||||||
|
# For dev version, prefer the one with "dev" in the name
|
||||||
|
asset=$(jq -e -r "[.assets[] | select(.name | endswith(\"$ext\") and contains(\"dev\"))][0] // [.assets[] | select(.name | endswith(\"$ext\"))][0]" <<<"$resp") || return 1
|
||||||
|
else
|
||||||
|
# For non-dev versions, exclude dev builds and take the first match
|
||||||
|
asset=$(jq -e -r "[.assets[] | select(.name | endswith(\"$ext\") and (contains(\"dev\") | not))][0] // [.assets[] | select(.name | endswith(\"$ext\"))][0]" <<<"$resp") || return 1
|
||||||
|
fi
|
||||||
url=$(jq -r .url <<<"$asset")
|
url=$(jq -r .url <<<"$asset")
|
||||||
name=$(jq -r .name <<<"$asset")
|
name=$(jq -r .name <<<"$asset")
|
||||||
file="${dir}/${name}"
|
file="${dir}/${name}"
|
||||||
@@ -287,7 +295,7 @@ isoneof() {
|
|||||||
merge_splits() {
|
merge_splits() {
|
||||||
local bundle=$1 output=$2
|
local bundle=$1 output=$2
|
||||||
pr "Merging splits"
|
pr "Merging splits"
|
||||||
gh_dl "$TEMP_DIR/apkeditor.jar" "https://github.com/REAndroid/APKEditor/releases/download/V1.4.2/APKEditor-1.4.2.jar" >/dev/null || return 1
|
gh_dl "$TEMP_DIR/apkeditor.jar" "https://github.com/REAndroid/APKEditor/releases/download/V1.4.7/APKEditor-1.4.7.jar" >/dev/null || return 1
|
||||||
if ! OP=$(java -jar "$TEMP_DIR/apkeditor.jar" merge -i "${bundle}" -o "${bundle}.mzip" -clean-meta -f 2>&1); then
|
if ! OP=$(java -jar "$TEMP_DIR/apkeditor.jar" merge -i "${bundle}" -o "${bundle}.mzip" -clean-meta -f 2>&1); then
|
||||||
epr "Apkeditor ERROR: $OP"
|
epr "Apkeditor ERROR: $OP"
|
||||||
return 1
|
return 1
|
||||||
@@ -312,23 +320,32 @@ merge_splits() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# -------------------- apkmirror --------------------
|
# -------------------- apkmirror --------------------
|
||||||
apk_mirror_search() {
|
apkmirror_search() {
|
||||||
local resp="$1" dpi="$2" arch="$3" apk_bundle="$4"
|
local resp="$1" dpi="$2" arch="$3" apk_bundle="$4"
|
||||||
local apparch dlurl node app_table
|
local apparch dlurl="" node app_table emptyCheck
|
||||||
if [ "$arch" = all ]; then
|
if [ "$arch" = all ]; then
|
||||||
apparch=(universal noarch 'arm64-v8a + armeabi-v7a')
|
apparch=(universal noarch 'arm64-v8a + armeabi-v7a')
|
||||||
else apparch=("$arch" universal noarch 'arm64-v8a + armeabi-v7a'); fi
|
else apparch=("$arch" universal noarch 'arm64-v8a + armeabi-v7a'); fi
|
||||||
for ((n = 1; n < 40; n++)); do
|
for ((n = 1; n < 40; n++)); do
|
||||||
node=$($HTMLQ "div.table-row.headerFont:nth-last-child($n)" -r "span:nth-child(n+3)" <<<"$resp")
|
node=$($HTMLQ "div.table-row.headerFont:nth-last-child($n)" -r "span:nth-child(n+3)" <<<"$resp")
|
||||||
if [ -z "$node" ]; then break; fi
|
if [ -z "$node" ]; then break; fi
|
||||||
app_table=$($HTMLQ --text --ignore-whitespace <<<"$node")
|
emptyCheck=$($HTMLQ -t -w "div.table-cell:nth-child(1) > a:nth-child(1)" --attribute class <<<"$node" | xargs)
|
||||||
if [ "$(sed -n 3p <<<"$app_table")" = "$apk_bundle" ] && [ "$(sed -n 6p <<<"$app_table")" = "$dpi" ] &&
|
if [ "$emptyCheck" ]; then
|
||||||
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")
|
dlurl=$($HTMLQ --base https://www.apkmirror.com --attribute href "div:nth-child(1) > a:nth-child(1)" <<<"$node")
|
||||||
|
else break; fi
|
||||||
|
app_table=$($HTMLQ --text --ignore-whitespace <<<"$node")
|
||||||
|
if [ "$(sed -n 3p <<<"$app_table")" = "$apk_bundle" ] &&
|
||||||
|
[ "$(sed -n 6p <<<"$app_table")" = "$dpi" ] &&
|
||||||
|
isoneof "$(sed -n 4p <<<"$app_table")" "${apparch[@]}"; then
|
||||||
echo "$dlurl"
|
echo "$dlurl"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ "$n" -eq 2 ] && [ "$dlurl" ]; then
|
||||||
|
# only one apk exists, return it
|
||||||
|
echo "$dlurl"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
dl_apkmirror() {
|
dl_apkmirror() {
|
||||||
@@ -337,18 +354,21 @@ dl_apkmirror() {
|
|||||||
is_bundle=true
|
is_bundle=true
|
||||||
else
|
else
|
||||||
if [ "$arch" = "arm-v7a" ]; then arch="armeabi-v7a"; fi
|
if [ "$arch" = "arm-v7a" ]; then arch="armeabi-v7a"; fi
|
||||||
local resp node app_table uurl dlurl=""
|
local resp node app_table apkmname dlurl=""
|
||||||
uurl=$(grep -F "downloadLink" <<<"$__APKMIRROR_RESP__" | grep -F "${version//./-}-release/" | head -1 |
|
apkmname=$($HTMLQ "h1.marginZero" --text <<<"$__APKMIRROR_RESP__")
|
||||||
sed -n 's;.*href="\(.*-release\).*;\1;p')
|
apkmname="${apkmname,,}" apkmname="${apkmname// /-}" apkmname="${apkmname//[^a-z0-9-]/}"
|
||||||
if [ -z "$uurl" ]; then url="${url}/${url##*/}-${version//./-}-release/"; else url=https://www.apkmirror.com$uurl; fi
|
url="${url}/${apkmname}-${version//./-}-release/"
|
||||||
resp=$(req "$url" -) || return 1
|
resp=$(req "$url" -) || return 1
|
||||||
node=$($HTMLQ "div.table-row.headerFont:nth-last-child(1)" -r "span:nth-child(n+3)" <<<"$resp")
|
node=$($HTMLQ "div.table-row.headerFont:nth-last-child(1)" -r "span:nth-child(n+3)" <<<"$resp")
|
||||||
if [ "$node" ]; then
|
if [ "$node" ]; then
|
||||||
if ! dlurl=$(apk_mirror_search "$resp" "$dpi" "${arch}" "APK"); then
|
for current_dpi in $dpi; do
|
||||||
if ! dlurl=$(apk_mirror_search "$resp" "$dpi" "${arch}" "BUNDLE"); then
|
for type in APK BUNDLE; do
|
||||||
return 1
|
if dlurl=$(apkmirror_search "$resp" "$current_dpi" "${arch}" "$type"); then
|
||||||
else is_bundle=true; fi
|
[[ "$type" == "BUNDLE" ]] && is_bundle=true || is_bundle=false
|
||||||
fi
|
break 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
[ -z "$dlurl" ] && return 1
|
[ -z "$dlurl" ] && return 1
|
||||||
resp=$(req "$dlurl" -)
|
resp=$(req "$dlurl" -)
|
||||||
fi
|
fi
|
||||||
@@ -381,14 +401,14 @@ get_apkmirror_vers() {
|
|||||||
}
|
}
|
||||||
get_apkmirror_pkg_name() { sed -n 's;.*id=\(.*\)" class="accent_color.*;\1;p' <<<"$__APKMIRROR_RESP__"; }
|
get_apkmirror_pkg_name() { sed -n 's;.*id=\(.*\)" class="accent_color.*;\1;p' <<<"$__APKMIRROR_RESP__"; }
|
||||||
get_apkmirror_resp() {
|
get_apkmirror_resp() {
|
||||||
__APKMIRROR_RESP__=$(req "${1}" -)
|
__APKMIRROR_RESP__=$(req "${1}" -) || return 1
|
||||||
__APKMIRROR_CAT__="${1##*/}"
|
__APKMIRROR_CAT__="${1##*/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# -------------------- uptodown --------------------
|
# -------------------- uptodown --------------------
|
||||||
get_uptodown_resp() {
|
get_uptodown_resp() {
|
||||||
__UPTODOWN_RESP__=$(req "${1}/versions" -)
|
__UPTODOWN_RESP__=$(req "${1}/versions" -) || return 1
|
||||||
__UPTODOWN_RESP_PKG__=$(req "${1}/download" -)
|
__UPTODOWN_RESP_PKG__=$(req "${1}/download" -) || return 1
|
||||||
}
|
}
|
||||||
get_uptodown_vers() { $HTMLQ --text ".version" <<<"$__UPTODOWN_RESP__"; }
|
get_uptodown_vers() { $HTMLQ --text ".version" <<<"$__UPTODOWN_RESP__"; }
|
||||||
dl_uptodown() {
|
dl_uptodown() {
|
||||||
@@ -396,14 +416,14 @@ dl_uptodown() {
|
|||||||
local apparch
|
local apparch
|
||||||
if [ "$arch" = "arm-v7a" ]; then arch="armeabi-v7a"; fi
|
if [ "$arch" = "arm-v7a" ]; then arch="armeabi-v7a"; fi
|
||||||
if [ "$arch" = all ]; then
|
if [ "$arch" = all ]; then
|
||||||
apparch=('arm64-v8a, armeabi-v7a, x86, x86_64' 'arm64-v8a, armeabi-v7a')
|
apparch=('arm64-v8a, armeabi-v7a, x86_64' '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
|
else apparch=("$arch" 'arm64-v8a, armeabi-v7a, x86_64' 'arm64-v8a, armeabi-v7a, x86, x86_64' 'arm64-v8a, armeabi-v7a'); fi
|
||||||
|
|
||||||
local op resp data_code
|
local op resp data_code
|
||||||
data_code=$($HTMLQ "#detail-app-name" --attribute data-code <<<"$__UPTODOWN_RESP__")
|
data_code=$($HTMLQ "#detail-app-name" --attribute data-code <<<"$__UPTODOWN_RESP__")
|
||||||
local versionURL=""
|
local versionURL=""
|
||||||
local is_bundle=false
|
local is_bundle=false
|
||||||
for i in {1..5}; do
|
for i in {1..20}; do
|
||||||
resp=$(req "${uptodown_dlurl}/apps/${data_code}/versions/${i}" -)
|
resp=$(req "${uptodown_dlurl}/apps/${data_code}/versions/${i}" -)
|
||||||
if ! op=$(jq -e -r ".data | map(select(.version == \"${version}\")) | .[0]" <<<"$resp"); then
|
if ! op=$(jq -e -r ".data | map(select(.version == \"${version}\")) | .[0]" <<<"$resp"); then
|
||||||
continue
|
continue
|
||||||
@@ -412,20 +432,30 @@ dl_uptodown() {
|
|||||||
if versionURL=$(jq -e -r '.versionURL' <<<"$op"); then break; else return 1; fi
|
if versionURL=$(jq -e -r '.versionURL' <<<"$op"); then break; else return 1; fi
|
||||||
done
|
done
|
||||||
if [ -z "$versionURL" ]; then return 1; fi
|
if [ -z "$versionURL" ]; then return 1; fi
|
||||||
|
versionURL=$(jq -e -r '.url + "/" + .extraURL + "/" + (.versionID | tostring)' <<<"$versionURL")
|
||||||
resp=$(req "$versionURL" -) || return 1
|
resp=$(req "$versionURL" -) || return 1
|
||||||
|
|
||||||
local data_version files node_arch data_file_id
|
local data_version files node_arch="" data_file_id node_class
|
||||||
data_version=$($HTMLQ '.button.variants' --attribute data-version <<<"$resp") || return 1
|
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
|
if [ "$data_version" ]; then
|
||||||
for ((n = 1; n < 12; n += 2)); do
|
files=$(req "${uptodown_dlurl%/*}/app/${data_code}/version/${data_version}/files" - | jq -e -r .content) || return 1
|
||||||
node_arch=$($HTMLQ ".content > p:nth-child($n)" --text <<<"$files" | xargs) || return 1
|
for ((n = 1; n < 12; n += 1)); do
|
||||||
if [ -z "$node_arch" ]; then return 1; fi
|
node_class=$($HTMLQ -w -t ".content > :nth-child($n)" --attribute class <<<"$files") || return 1
|
||||||
if ! isoneof "$node_arch" "${apparch[@]}"; then continue; fi
|
if [ "$node_class" != "variant" ]; then
|
||||||
data_file_id=$($HTMLQ "div.variant:nth-child($((n + 1))) > .v-report" --attribute data-file-id <<<"$files") || return 1
|
node_arch=$($HTMLQ -w -t ".content > :nth-child($n)" <<<"$files" | xargs) || return 1
|
||||||
resp=$(req "${uptodown_dlurl}/download/${data_file_id}-x" -)
|
continue
|
||||||
break
|
fi
|
||||||
done
|
if [ -z "$node_arch" ]; then return 1; fi
|
||||||
|
if ! isoneof "$node_arch" "${apparch[@]}"; then continue; fi
|
||||||
|
|
||||||
|
file_type=$($HTMLQ -w -t ".content > :nth-child($n) > .v-file > span" <<<"$files") || return 1
|
||||||
|
if [ "$file_type" = "xapk" ]; then is_bundle=true; else is_bundle=false; fi
|
||||||
|
data_file_id=$($HTMLQ ".content > :nth-child($n) > .v-report" --attribute data-file-id <<<"$files") || return 1
|
||||||
|
resp=$(req "${uptodown_dlurl}/download/${data_file_id}-x" -)
|
||||||
|
break
|
||||||
|
done
|
||||||
|
if [ $n -eq 12 ]; then return 1; fi
|
||||||
|
fi
|
||||||
local data_url
|
local data_url
|
||||||
data_url=$($HTMLQ "#detail-download-button" --attribute data-url <<<"$resp") || return 1
|
data_url=$($HTMLQ "#detail-download-button" --attribute data-url <<<"$resp") || return 1
|
||||||
if [ $is_bundle = true ]; then
|
if [ $is_bundle = true ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user