Skip to content

Commit 32f8518

Browse files
shirai-koupeternmuller
authored andcommitted
Allow multiple dpi for apkmirror (#718)
Introduce an option that allows multiple dpi versions to be searched in order and make this option by default. The current implementation allow this list to be changed from the config.toml using a global variable like: dpi = "nodpi anydpi 120-640dpi" By default, only "nodpi" and "anydpi" are searched.
1 parent 9774718 commit 32f8518

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CONFIG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ There exists an example below with all defaults shown and all the keys explicitl
1919
parallel-jobs = 1 # amount of cores to use for parallel patching, if not set $(nproc) is used
2020
compression-level = 9 # module zip compression level
2121
remove-rv-integrations-checks = true # remove checks from the revanced integrations
22+
dpi = "nodpi anydpi 120-640dpi" # dpi packages to be searched in order. default: "nodpi anydpi"
2223

2324
patches-source = "revanced/revanced-patches" # where to fetch patches bundle from. default: "revanced/revanced-patches"
2425
cli-source = "j-hc/revanced-cli" # where to fetch cli from. default: "j-hc/revanced-cli"

build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ DEF_CLI_VER=$(toml_get "$main_config_t" cli-version) || DEF_CLI_VER="latest"
3232
DEF_PATCHES_SRC=$(toml_get "$main_config_t" patches-source) || DEF_PATCHES_SRC="ReVanced/revanced-patches"
3333
DEF_CLI_SRC=$(toml_get "$main_config_t" cli-source) || DEF_CLI_SRC="j-hc/revanced-cli"
3434
DEF_RV_BRAND=$(toml_get "$main_config_t" rv-brand) || DEF_RV_BRAND="ReVanced"
35+
DEF_DPI_LIST=$(toml_get "$main_config_t" dpi) || DEF_DPI_LIST="nodpi anydpi"
3536
mkdir -p "$TEMP_DIR" "$BUILD_DIR"
3637

3738
if [ "${2-}" = "--config-update" ]; then
@@ -130,7 +131,8 @@ for table_name in $(toml_get_table_names); do
130131
fi
131132

132133
app_args[include_stock]=$(toml_get "$t" include-stock) || app_args[include_stock]=true && vtf "${app_args[include_stock]}" "include-stock"
133-
app_args[dpi]=$(toml_get "$t" dpi) || app_args[dpi]="nodpi"
134+
app_args[dpi]=$(toml_get "$t" dpi) || app_args[dpi]="$DEF_DPI_LIST"
135+
read -r -a DPI_CANDIDATES <<<"${app_args[dpi]}"
134136
table_name_f=${table_name,,}
135137
table_name_f=${table_name_f// /-}
136138
app_args[module_prop_name]=$(toml_get "$t" module-prop-name) || app_args[module_prop_name]="${table_name_f}-peternmuller"

utils.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,14 @@ dl_apkmirror() {
326326
resp=$(req "$url" -) || return 1
327327
node=$($HTMLQ "div.table-row.headerFont:nth-last-child(1)" -r "span:nth-child(n+3)" <<<"$resp")
328328
if [ "$node" ]; then
329-
if ! dlurl=$(apk_mirror_search "$resp" "$dpi" "${arch}" "APK"); then
330-
if ! dlurl=$(apk_mirror_search "$resp" "$dpi" "${arch}" "BUNDLE"); then
331-
return 1
332-
else is_bundle=true; fi
333-
fi
329+
for current_dpi in "${dpi[@]}"; do
330+
for type in APK BUNDLE; do
331+
if dlurl=$(apk_mirror_search "$resp" "$current_dpi" "${arch}" "$type"); then
332+
[[ "$type" == "BUNDLE" ]] && is_bundle=true || is_bundle=false
333+
break 2
334+
fi
335+
done
336+
done
334337
[ -z "$dlurl" ] && return 1
335338
resp=$(req "$dlurl" -)
336339
fi
@@ -536,8 +539,8 @@ build_rv() {
536539
if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi
537540
pr "Downloading '${table}' from ${dl_p}"
538541
if ! isoneof $dl_p "${tried_dl[@]}"; then get_${dl_p}_resp "${args[${dl_p}_dlurl]}"; fi
539-
if ! dl_${dl_p} "${args[${dl_p}_dlurl]}" "$version" "$stock_apk" "$arch" "${args[dpi]}" "$get_latest_ver"; then
540-
epr "ERROR: Could not download '${table}' from ${dl_p} with version '${version}', arch '${arch}', dpi '${args[dpi]}'"
542+
if ! dl_${dl_p} "${args[${dl_p}_dlurl]}" "$version" "$stock_apk" "$arch" "$DPI_CANDIDATES" "$get_latest_ver"; then
543+
epr "ERROR: Could not download '${table}' from ${dl_p} with version '${version}', arch '${arch}', dpi '${DPI_CANDIDATES[*]}'"
541544
continue
542545
fi
543546
break

0 commit comments

Comments
 (0)