Skip to content

Commit

Permalink
Merge branch 'sync-upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
RiverOnVenus committed Jun 13, 2024
2 parents f3b1d65 + 68be17f commit daeb3b5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 31 deletions.
2 changes: 0 additions & 2 deletions CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Adding another revanced app is as easy as this:
[Some-App]
apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app"
# or uptodown-dlurl = "https://app.en.uptodown.com/android"
# or apkmonk-dlurl = "https://www.apkmonk.com/app/com.app.app/"
```

## More about other options:
Expand Down Expand Up @@ -37,7 +36,6 @@ included-patches = "'Patch something'" # whitespace seperated list of patches to
exclusive-patches = false # exclude all patches by default. default: false
apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app"
uptodown-dlurl = "https://spotify.en.uptodown.com/android"
apkmonk-dlurl = "https://www.apkmonk.com/app/com.app.app/"
module-prop-name = "some-app-magisk" # magisk module prop name.
apkmirror-dpi = "360-480dpi" # used to select apk variant from apkmirror. default: nodpi
arch = "arm64-v8a" # 'arm64-v8a', 'arm-v7a', 'all', 'both'. 'both' downloads both arm64-v8a and arm-v7a. default: all
Expand Down
6 changes: 1 addition & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ for table_name in $(toml_get_table_names); do
app_args[uptodown_dlurl]=${app_args[uptodown_dlurl]%/}
app_args[dl_from]=uptodown
} || app_args[uptodown_dlurl]=""
app_args[apkmonk_dlurl]=$(toml_get "$t" apkmonk-dlurl) && {
app_args[apkmonk_dlurl]=${app_args[apkmonk_dlurl]%/}
app_args[dl_from]=apkmonk
} || app_args[apkmonk_dlurl]=""
app_args[apkmirror_dlurl]=$(toml_get "$t" apkmirror-dlurl) && {
app_args[apkmirror_dlurl]=${app_args[apkmirror_dlurl]%/}
app_args[dl_from]=apkmirror
Expand All @@ -139,7 +135,7 @@ for table_name in $(toml_get_table_names); do
app_args[archive_dlurl]=${app_args[archive_dlurl]%/}
app_args[dl_from]=archive
} || app_args[archive_dlurl]=""
if [ -z "${app_args[dl_from]-}" ]; then abort "ERROR: no 'apkmirror_dlurl', 'uptodown_dlurl' or 'apkmonk_dlurl' option was set for '$table_name'."; fi
if [ -z "${app_args[dl_from]-}" ]; then abort "ERROR: no 'apkmirror_dlurl', 'uptodown_dlurl' or 'archive_dlurl' option was set for '$table_name'."; fi
app_args[arch]=$(toml_get "$t" arch) || app_args[arch]="all"
if [ "${app_args[arch]}" != "both" ] && [ "${app_args[arch]}" != "all" ] && [[ ${app_args[arch]} != "arm64-v8a"* ]] && [[ ${app_args[arch]} != "arm-v7a"* ]]; then
abort "wrong arch '${app_args[arch]}' for '$table_name'"
Expand Down
52 changes: 28 additions & 24 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ NEXT_VER_CODE=${NEXT_VER_CODE:-$(date +'%Y%m%d')}
REBUILD=${REBUILD:-false}
OS=$(uname -o)

# -------------------- json/toml --------------------
toml_prep() { __TOML__=$(tr -d '\t\r' <<<"$1" | tr "'" '"' | grep -o '^[^#]*' | grep -v '^$' | sed -r 's/(\".*\")|\s*/\1/g; 1i []'); }
toml_get_table_names() {
local tn
Expand All @@ -25,7 +24,6 @@ toml_get() {
local table=$1 key=$2 val
val=$(grep -m 1 "^${key}=" <<<"$table") && sed -e "s/^\"//; s/\"$//" <<<"${val#*=}"
}
# ---------------------------------------------------

pr() { echo -e "\033[0;32m[+] ${1}\033[0m"; }
epr() {
Expand Down Expand Up @@ -254,7 +252,6 @@ get_apkmirror_resp() {
__APKMIRROR_RESP__=$(req "${1}" -)
__APKMIRROR_CAT__="${1##*/}"
}
# --------------------------------------------------

# -------------------- uptodown --------------------
get_uptodown_resp() {
Expand All @@ -263,29 +260,36 @@ get_uptodown_resp() {
}
get_uptodown_vers() { $HTMLQ --text ".version" <<<"$__UPTODOWN_RESP__"; }
dl_uptodown() {
local uptodown_dlurl=$1 version=$2 output=$3
local uptodown_dlurl=$1 version=$2 output=$3 arch=$4 is_latest=$6
local url
url=$(grep -F "${version}</span>" -B 2 <<<"$__UPTODOWN_RESP__" | head -1 | sed -n 's;.*data-url=".*download\/\(.*\)".*;\1;p') || return 1
url="https://dw.uptodown.com/dwn/$(req "${uptodown_dlurl}/post-download/${url}" - | sed -n 's;.*class="post-download" data-url="\(.*\)".*;\1;p')" || return 1
if [ "$is_latest" = false ]; then
url=$(grep -F "${version}</span>" -B 2 <<<"$__UPTODOWN_RESP__" | head -1 | sed -n 's;.*data-url=".*download\/\(.*\)".*;\1;p') || return 1
url="/$url"
else url=""; fi
if [ "$arch" != all ]; then
local app_code data_version files node_arch content resp
if [ "$is_latest" = false ]; then
resp=$(req "${1}/download${url}" -)
else resp="$__UPTODOWN_RESP_PKG__"; fi
app_code=$($HTMLQ "#detail-app-name" --attribute code <<<"$resp")
data_version=$($HTMLQ "button.button:nth-child(2)" --attribute data-version <<<"$resp")
files=$(req "${uptodown_dlurl%/*}/app/${app_code}/version/${data_version}/files" - | jq -r .content)
for ((n = 1; n < 40; n++)); 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
content=$($HTMLQ "div.variant:nth-child($((n + 1)))" <<<"$files")
url=$(sed -n "s;.*'.*android\/post-download\/\(.*\)'.*;\1;p" <<<"$content" | head -1)
url="/$url"
break
done
fi
url="https://dw.uptodown.com/dwn/$(req "${uptodown_dlurl}/post-download${url}" - | sed -n 's;.*class="post-download" data-url="\(.*\)".*;\1;p')" || return 1
req "$url" "$output"
}
get_uptodown_pkg_name() { $HTMLQ --text "tr.full:nth-child(1) > td:nth-child(3)" <<<"$__UPTODOWN_RESP_PKG__"; }
# --------------------------------------------------

# -------------------- apkmonk ---------------------
get_apkmonk_resp() {
__APKMONK_RESP__=$(req "${1}" -)
__APKMONK_PKG_NAME__=$(awk -F/ '{print $NF}' <<<"$1")
}
get_apkmonk_vers() { grep -oP 'download_ver.+?>\K([0-9,\.]*)' <<<"$__APKMONK_RESP__"; }
dl_apkmonk() {
local url=$1 version=$2 output=$3
url="https://www.apkmonk.com/down_file?pkg="$(grep -F "$version</a>" <<<"$__APKMONK_RESP__" | grep -oP 'href=\"/download-app/\K.+?(?=/?\">)' | sed 's;/;\&key=;') || return 1
url=$(req "$url" - | grep -oP 'https.+?(?=\",)') || return 1
req "$url" "$output"
}
get_apkmonk_pkg_name() { echo "$__APKMONK_PKG_NAME__"; }
# --------------------------------------------------
# -------------------- archive --------------------
dl_archive() {
local url=$1 version=$2 output=$3 arch=$4
local path version=${version// /}
Expand Down Expand Up @@ -337,7 +341,7 @@ build_rv() {
p_patcher_args+=("$(join_args "${args[excluded_patches]}" -e) $(join_args "${args[included_patches]}" -i)")
[ "${args[exclusive_patches]}" = true ] && p_patcher_args+=("--exclusive")

for dl_p in archive apkmirror uptodown apkmonk; do
for dl_p in archive apkmirror uptodown; do
if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi
if ! get_"${dl_p}"_resp "${args[${dl_p}_dlurl]}" || ! pkg_name=$(get_"${dl_p}"_pkg_name); then
args[${dl_p}_dlurl]=""
Expand Down Expand Up @@ -378,10 +382,10 @@ build_rv() {
version_f=${version_f#v}
local stock_apk="${TEMP_DIR}/${pkg_name}-${version_f}-${arch_f}.apk"
if [ ! -f "$stock_apk" ]; then
for dl_p in archive apkmirror uptodown apkmonk; do
for dl_p in archive apkmirror uptodown; do
if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi
pr "Downloading '${table}' from ${dl_p}"
if ! dl_${dl_p} "${args[${dl_p}_dlurl]}" "$version" "$stock_apk" "$arch" "${args[dpi]}"; then
if ! dl_${dl_p} "${args[${dl_p}_dlurl]}" "$version" "$stock_apk" "$arch" "${args[dpi]}" "$get_latest_ver"; then
epr "ERROR: Could not download '${table}' from ${dl_p} with version '${version}', arch '${arch}', dpi '${args[dpi]}'"
continue
fi
Expand Down

0 comments on commit daeb3b5

Please sign in to comment.