Compare commits

..
13 Commits
Author SHA1 Message Date
Nezumi-2711 5785b1594a fix: apk download 2026-03-17 10:34:16 +07:00
Nezumi-2711 03625a35d5 fix: apk download 2026-03-17 10:05:39 +07:00
Nezumi-2711 bc51731aeb fix: apk download 2026-03-17 10:02:30 +07:00
Nezumi-2711 f0b44a12a1 fix: apk download 2026-03-17 09:55:23 +07:00
Nezumi-2711 ffa6e7a357 fix: download apk 2026-03-16 18:38:24 +07:00
Nezumi-2711 e8297c8d9a fix: download apk 2026-03-16 18:30:57 +07:00
Nezumi-2711 bb1398a32f fix: download apk 2026-03-16 18:14:38 +07:00
Nezumi-2711 34d34bc878 fix: download apk 2026-03-16 18:00:53 +07:00
nezumi d24f8939d0 fix: download apk issues 2026-02-24 17:04:12 +07:00
nezumi 3becfad4f7 fix: resolve the utils logic 2026-01-17 13:03:35 +07:00
nezumi 0e85707946 fix: resolve the utils logic 2026-01-17 12:58:05 +07:00
nezumi 117a2fde1b Update email content: add changelog, separate APKs/Modules, use Vietnam timezone 2026-01-09 22:27:26 +07:00
nezumi 8d9c8d40aa Add email notification feature using Resend API 2026-01-09 22:10:54 +07:00
6 changed files with 382 additions and 54 deletions
+152 -9
View File
@@ -16,8 +16,8 @@ jobs:
steps:
- uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "17"
distribution: 'zulu'
java-version: '17'
- name: Checkout
uses: actions/checkout@v4
@@ -175,7 +175,7 @@ jobs:
**Download Links:**
"
MODULES_MSG="
**Modules:**
${MODULES}
@@ -189,15 +189,15 @@ jobs:
curl -X POST -H "Content-Type: application/json" \
-d "$(jq -n --arg content "$MSG" '{content: $content}')" \
"$DISCORD_WEBHOOK_URL"
# curl -X POST -H "Content-Type: application/json" \
# -d "$(jq -n --arg content "$MODULES_MSG" '{content: $content}')" \
# "$DISCORD_WEBHOOK_URL"
curl -X POST -H "Content-Type: application/json" \
-d "$(jq -n --arg content "$APKS_MSG" '{content: $content}')" \
"$DISCORD_WEBHOOK_URL"
- name: Report to Noob Discord
env:
DISCORD_WEBHOOK_NOOB_URL: ${{ secrets.DISCORD_WEBHOOK_NOOB_URL }}
@@ -227,7 +227,7 @@ jobs:
**Download Links:**
"
MODULES_MSG="
**Modules:**
${MODULES}
@@ -241,11 +241,154 @@ jobs:
curl -X POST -H "Content-Type: application/json" \
-d "$(jq -n --arg content "$MSG" '{content: $content}')" \
"$DISCORD_WEBHOOK_NOOB_URL"
# curl -X POST -H "Content-Type: application/json" \
# -d "$(jq -n --arg content "$MODULES_MSG" '{content: $content}')" \
# "$DISCORD_WEBHOOK_NOOB_URL"
curl -X POST -H "Content-Type: application/json" \
-d "$(jq -n --arg content "$APKS_MSG" '{content: $content}')" \
"$DISCORD_WEBHOOK_NOOB_URL"
- name: Send Email Notification (Resend)
env:
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
MAIL_TO: ${{ secrets.MAIL_TO }}
MAIL_CC: ${{ secrets.MAIL_CC }}
MAIL_BCC: ${{ secrets.MAIL_BCC }}
MAIL_FROM: ${{ secrets.MAIL_FROM }}
if: env.RESEND_API_KEY != null && env.MAIL_TO != null
run: |
VERSION="${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}"
RELEASE_URL="${{ github.server_url }}/${{ github.repository }}/releases/tag/${VERSION}"
REPO="${{ github.repository }}"
# Set default FROM address if not provided
FROM_ADDRESS="${MAIL_FROM:-ReVanced Build Bot <onboarding@resend.dev>}"
# Build download links from build folder (separate APKs and Modules)
cd build || { echo "build folder not found"; exit 1; }
APK_LINKS=""
MODULE_LINKS=""
for OUTPUT in *; do
DL_URL="${{ github.server_url }}/${{ github.repository }}/releases/download/${VERSION}/${OUTPUT}"
if [[ $OUTPUT = *.apk ]]; then
APK_LINKS+="<li style=\"margin: 8px 0;\">📦 <a href=\"${DL_URL}\" style=\"color: #667eea; text-decoration: none;\">${OUTPUT}</a></li>"
elif [[ $OUTPUT = *.zip ]]; then
MODULE_LINKS+="<li style=\"margin: 8px 0;\">📁 <a href=\"${DL_URL}\" style=\"color: #667eea; text-decoration: none;\">${OUTPUT}</a></li>"
fi
done
cd ..
# Get current time in Vietnam timezone (UTC+7)
BUILD_TIME=$(TZ='Asia/Ho_Chi_Minh' date '+%Y-%m-%d %H:%M:%S (UTC+7)')
# Get changelog from build.md and convert to HTML
if [ -f "build.md" ]; then
# Convert markdown to simple HTML
CHANGELOG_HTML=$(sed 's/^### \(.*\)/<h3 style="color: #667eea; font-size: 16px; margin: 15px 0 8px 0;">\1<\/h3>/g;
s/^\* \*\*\(.*\)\*\*/<li style="margin: 5px 0;"><strong>\1<\/strong><\/li>/g;
s/^\* \(.*\)/<li style="margin: 5px 0;">\1<\/li>/g;
s/^- \(.*\)/<li style="margin: 5px 0;">\1<\/li>/g;
s/`\([^`]*\)`/<code style="background: #e9ecef; padding: 2px 6px; border-radius: 3px; font-size: 13px;">\1<\/code>/g;
/^==/d;
/^$/d' build.md | tr '\n' ' ')
else
CHANGELOG_HTML="<p>No changelog available.</p>"
fi
# Create HTML email body (similar structure to Telegram)
HTML_BODY=$(cat <<EOF
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 0;">
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; text-align: center;">
<h1 style="margin: 0;">🎉 New ReVanced Build!</h1>
<p style="margin: 10px 0 0 0; font-size: 18px;">Version: v${VERSION}</p>
<p style="margin: 5px 0 0 0; font-size: 14px; opacity: 0.9;">🕐 ${BUILD_TIME}</p>
</div>
<div style="padding: 25px; background: #f9f9f9;">
<!-- Changelog Section -->
<div style="margin-bottom: 25px; background: white; padding: 20px; border-radius: 8px; border-left: 4px solid #667eea;">
<h2 style="color: #667eea; font-size: 18px; margin: 0 0 15px 0;">📋 Changelog</h2>
<div style="font-size: 14px;">
${CHANGELOG_HTML}
</div>
</div>
<!-- Download Links Section -->
<div style="margin-bottom: 25px; background: white; padding: 20px; border-radius: 8px;">
<h2 style="color: #667eea; font-size: 18px; margin: 0 0 15px 0;"> Download Links</h2>
<!-- Modules -->
$(if [ -n "$MODULE_LINKS" ]; then echo "
<div style=\"margin-bottom: 15px;\">
<h3 style=\"color: #555; font-size: 15px; margin: 0 0 10px 0;\"> Modules:</h3>
<ul style=\"list-style: none; padding: 0; margin: 0;\">
${MODULE_LINKS}
</ul>
</div>
"; fi)
<!-- APKs -->
$(if [ -n "$APK_LINKS" ]; then echo "
<div>
<h3 style=\"color: #555; font-size: 15px; margin: 0 0 10px 0;\">📱 APKs:</h3>
<ul style=\"list-style: none; padding: 0; margin: 0;\">
${APK_LINKS}
</ul>
</div>
"; fi)
</div>
<!-- GitHub Button -->
<div style="text-align: center;">
<a href="${RELEASE_URL}" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 30px; text-decoration: none; border-radius: 25px; font-weight: bold;">
View Release on GitHub
</a>
</div>
</div>
<div style="text-align: center; padding: 20px; background: #333; color: #999; font-size: 12px;">
<p style="margin: 0;">This is an automated message from ReVanced Build Bot</p>
<p style="margin: 5px 0 0 0;">Repository: ${REPO}</p>
</div>
</body>
</html>
EOF
)
# Build JSON payload with TO, CC and BCC recipients
# Resend allows up to 50 recipients per field (to, cc, bcc)
JSON_PAYLOAD=$(jq -n \
--arg from "$FROM_ADDRESS" \
--arg to "$MAIL_TO" \
--arg cc "$MAIL_CC" \
--arg bcc "$MAIL_BCC" \
--arg subject "🚀 New ReVanced Build Available - v${VERSION}" \
--arg html "$HTML_BODY" \
'{
from: $from,
to: ($to | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; ""))),
subject: $subject,
html: $html
}
+ (if $cc != "" then {cc: ($cc | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; "")))} else {} end)
+ (if $bcc != "" then {bcc: ($bcc | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; "")))} else {} end)'
)
echo "📧 Sending email notification..."
# Send email via Resend API
RESPONSE=$(curl -s -X POST "https://api.resend.com/emails" \
-H "Authorization: Bearer ${RESEND_API_KEY}" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD")
echo "Response: $RESPONSE"
echo "✅ Email sent successfully!"
+127
View File
@@ -0,0 +1,127 @@
name: Email Notification Test
on:
workflow_dispatch:
inputs:
recipient_email:
description: 'Email address to send test to (leave empty to use MAIL_TO secret)'
required: false
type: string
jobs:
send-test-email:
runs-on: ubuntu-latest
steps:
- name: Send Test Email (Resend)
env:
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
MAIL_TO: ${{ inputs.recipient_email || secrets.MAIL_TO }}
MAIL_CC: ${{ secrets.MAIL_CC }}
MAIL_BCC: ${{ secrets.MAIL_BCC }}
MAIL_FROM: ${{ secrets.MAIL_FROM }}
run: |
if [ -z "$RESEND_API_KEY" ]; then
echo "❌ Error: RESEND_API_KEY secret is not set!"
exit 1
fi
if [ -z "$MAIL_TO" ]; then
echo "❌ Error: No email recipient specified!"
echo "Either provide recipient_email input or set MAIL_TO secret."
exit 1
fi
# Set default FROM address if not provided
FROM_ADDRESS="${MAIL_FROM:-ReVanced Build Bot <onboarding@resend.dev>}"
# Use Vietnam timezone (UTC+7)
VERSION="TEST-$(TZ='Asia/Ho_Chi_Minh' date +%Y%m%d-%H%M%S)"
SENT_TIME=$(TZ='Asia/Ho_Chi_Minh' date '+%Y-%m-%d %H:%M:%S (UTC+7)')
RELEASE_URL="${{ github.server_url }}/${{ github.repository }}/releases"
REPO="${{ github.repository }}"
# Create test HTML email body
HTML_BODY=$(cat <<EOF
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 0;">
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; text-align: center;">
<h1 style="margin: 0;">🧪 Test Email</h1>
<p style="margin: 10px 0 0 0; font-size: 18px;">Version: ${VERSION}</p>
</div>
<div style="padding: 25px; background: #f9f9f9;">
<div style="margin-bottom: 25px;">
<h2 style="color: #667eea; font-size: 18px; margin: 0 0 10px 0;">✅ Email Configuration Working!</h2>
<p style="margin: 0;">If you received this email, it means your Resend configuration is working correctly!</p>
</div>
<div style="margin-bottom: 25px;">
<h2 style="color: #667eea; font-size: 18px; margin: 0 0 10px 0;">📋 Configuration Details</h2>
<ul style="list-style: none; padding: 0; margin: 0;">
<li>📧 From: ${FROM_ADDRESS}</li>
<li>📬 To: ${MAIL_TO}</li>
<li>🕐 Sent at: ${SENT_TIME}</li>
</ul>
</div>
<div style="margin-bottom: 25px; text-align: center;">
<a href="${RELEASE_URL}" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 30px; text-decoration: none; border-radius: 25px; font-weight: bold;">
View Releases
</a>
</div>
</div>
<div style="text-align: center; padding: 20px; background: #333; color: #999; font-size: 12px;">
<p style="margin: 0;">This is a TEST email from ReVanced Build Bot</p>
<p style="margin: 5px 0 0 0;">Repository: ${REPO}</p>
</div>
</body>
</html>
EOF
)
# Build JSON payload
JSON_PAYLOAD=$(jq -n \
--arg from "$FROM_ADDRESS" \
--arg to "$MAIL_TO" \
--arg cc "$MAIL_CC" \
--arg bcc "$MAIL_BCC" \
--arg subject "🧪 [TEST] ReVanced Build Email - ${VERSION}" \
--arg html "$HTML_BODY" \
'{
from: $from,
to: ($to | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; ""))),
subject: $subject,
html: $html
}
+ (if $cc != "" then {cc: ($cc | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; "")))} else {} end)
+ (if $bcc != "" then {bcc: ($bcc | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; "")))} else {} end)'
)
echo "📧 Sending test email to: $MAIL_TO"
if [ -n "$MAIL_CC" ]; then echo "📋 CC: $MAIL_CC"; fi
if [ -n "$MAIL_BCC" ]; then echo "🔒 BCC: $MAIL_BCC"; fi
echo ""
# Send email via Resend API
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "https://api.resend.com/emails" \
-H "Authorization: Bearer ${RESEND_API_KEY}" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')
echo "Response: $BODY"
echo "HTTP Code: $HTTP_CODE"
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
echo ""
echo "✅ Test email sent successfully!"
echo "📬 Check your inbox at: $MAIL_TO"
else
echo ""
echo "❌ Failed to send email!"
echo "Please check your RESEND_API_KEY and email addresses."
exit 1
fi
+2
View File
@@ -6,3 +6,5 @@ test*
/logs
build.md
cmpr
utils-refer.sh
+1 -1
View File
@@ -30,7 +30,7 @@ REMOVE_RV_INTEGRATIONS_CHECKS=$(toml_get "$main_config_t" remove-rv-integrations
DEF_PATCHES_VER=$(toml_get "$main_config_t" patches-version) || DEF_PATCHES_VER="latest"
DEF_CLI_VER=$(toml_get "$main_config_t" cli-version) || DEF_CLI_VER="latest"
DEF_PATCHES_SRC=$(toml_get "$main_config_t" patches-source) || DEF_PATCHES_SRC="ReVanced/revanced-patches"
DEF_CLI_SRC=$(toml_get "$main_config_t" cli-source) || DEF_CLI_SRC="j-hc/revanced-cli"
DEF_CLI_SRC=$(toml_get "$main_config_t" cli-source) || DEF_CLI_SRC="ReVanced/revanced-cli"
DEF_RV_BRAND=$(toml_get "$main_config_t" rv-brand) || DEF_RV_BRAND="ReVanced"
mkdir -p "$TEMP_DIR" "$BUILD_DIR"
+1
View File
@@ -28,6 +28,7 @@ arch = "both"
version = "auto"
apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/photos/"
uptodown-dlurl = "https://google-photos.en.uptodown.com/android"
archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.photos"
[Spotify]
uptodown-dlurl = "https://spotify.en.uptodown.com/android"
+99 -44
View File
@@ -99,7 +99,15 @@ get_rv_prebuilts() {
resp=$(gh_req "$rv_rel" -) || return 1
if [ "$ver" = "dev" ]; then resp=$(jq -r '.[0]' <<<"$resp"); fi
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")
name=$(jq -r .name <<<"$asset")
file="${dir}/${name}"
@@ -207,7 +215,7 @@ _req() {
local ip="$1" op="$2"
shift 2
if [ "$op" = - ]; then
if ! curl -L -c "$TEMP_DIR/cookie.txt" -b "$TEMP_DIR/cookie.txt" --connect-timeout 5 --retry 0 --fail -s -S "$@" "$ip"; then
if ! curl -L -c "$TEMP_DIR/cookie.txt" -b "$TEMP_DIR/cookie.txt" --connect-timeout 10 --retry 3 --retry-delay 2 --fail -s -S "$@" "$ip"; then
epr "Request failed: $ip"
return 1
fi
@@ -219,14 +227,19 @@ _req() {
while [ -f "$dlp" ]; do sleep 1; done
return
fi
if ! curl -L -c "$TEMP_DIR/cookie.txt" -b "$TEMP_DIR/cookie.txt" --connect-timeout 5 --retry 0 --fail -s -S "$@" "$ip" -o "$dlp"; then
if ! curl -L -c "$TEMP_DIR/cookie.txt" -b "$TEMP_DIR/cookie.txt" --connect-timeout 10 --retry 3 --retry-delay 2 --fail -s -S "$@" "$ip" -o "$dlp"; then
epr "Request failed: $ip"
return 1
fi
mv -f "$dlp" "$op"
fi
}
req() { _req "$1" "$2" -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0"; }
req() {
_req "$1" "$2" \
-H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0" \
-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8" \
-H "Accept-Language: en-US,en;q=0.5"
}
gh_req() { _req "$1" "$2" -H "$GH_HEADER"; }
gh_dl() {
if [ ! -f "$1" ]; then
@@ -267,16 +280,36 @@ get_patch_last_supported_ver() {
return
fi
fi
if ! op=$(java -jar "$rv_cli_jar" list-versions "$rv_patches_jar" -f "$pkg_name" 2>&1 | tail -n +3 | awk '{$1=$1}1'); then
epr "list-versions: '$op'"
return 1
fi
op=$(patches_list_versions "$rv_cli_jar" "$rv_patches_jar" "$pkg_name") || return 1
op=$(tail -n +3 <<<"$op" | awk '{$1=$1}1')
if [ "$op" = "Any" ]; then return; fi
pcount=$(head -1 <<<"$op") pcount=${pcount#*(} pcount=${pcount% *}
if [ -z "$pcount" ]; then abort "unreachable: '$pcount'"; fi
if [ -z "$pcount" ]; then abort "No patches found for '$pkg_name' in patches '$rv_patches_jar'"; fi
grep -F "($pcount patch" <<<"$op" | sed 's/ (.* patch.*//' | get_highest_ver || return 1
}
patches_list_versions() {
local cli_jar=$1 patches_jar=$2 pkg_name=$3 op
if ! op=$(java -jar "$cli_jar" list-versions -p "$patches_jar" -f "$pkg_name" -b 2>&1); then
if ! op=$(java -jar "$cli_jar" list-versions "$patches_jar" -f "$pkg_name" 2>&1); then
epr "Could not list versions $cli_jar: '$op'"
return 1
fi
fi
echo "$op"
}
patches_list() {
local cli_jar=$1 patches_jar=$2 pkg_name=$3 op
if ! op=$(java -jar "$cli_jar" list-patches -p "$patches_jar" --filter-package-name "$pkg_name" --versions --packages -b 2>&1); then
if ! op=$(java -jar "$cli_jar" list-patches --patches "$patches_jar" -f "$pkg_name" --with-versions --with-packages 2>&1); then
epr "Could not get patches list $cli_jar: '$op'"
return 1
fi
fi
echo "$op"
}
isoneof() {
local i=$1 v
shift
@@ -287,7 +320,7 @@ isoneof() {
merge_splits() {
local bundle=$1 output=$2
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
epr "Apkeditor ERROR: $OP"
return 1
@@ -312,23 +345,32 @@ merge_splits() {
}
# -------------------- apkmirror --------------------
apk_mirror_search() {
apkmirror_search() {
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
apparch=(universal noarch 'arm64-v8a + armeabi-v7a')
else apparch=("$arch" universal noarch 'arm64-v8a + armeabi-v7a'); fi
for ((n = 1; n < 40; n++)); do
node=$($HTMLQ "div.table-row.headerFont:nth-last-child($n)" -r "span:nth-child(n+3)" <<<"$resp")
if [ -z "$node" ]; then 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
emptyCheck=$($HTMLQ -t -w "div.table-cell:nth-child(1) > a:nth-child(1)" --attribute class <<<"$node" | xargs)
if [ "$emptyCheck" ]; then
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"
return 0
fi
done
if [ "$n" -eq 2 ] && [ "$dlurl" ]; then
# only one apk exists, return it
echo "$dlurl"
return 0
fi
return 1
}
dl_apkmirror() {
@@ -337,18 +379,21 @@ dl_apkmirror() {
is_bundle=true
else
if [ "$arch" = "arm-v7a" ]; then arch="armeabi-v7a"; fi
local resp node app_table uurl dlurl=""
uurl=$(grep -F "downloadLink" <<<"$__APKMIRROR_RESP__" | grep -F "${version//./-}-release/" | head -1 |
sed -n 's;.*href="\(.*-release\).*;\1;p')
if [ -z "$uurl" ]; then url="${url}/${url##*/}-${version//./-}-release/"; else url=https://www.apkmirror.com$uurl; fi
local resp node app_table apkmname dlurl=""
apkmname=$($HTMLQ "h1.marginZero" --text <<<"$__APKMIRROR_RESP__")
apkmname="${apkmname,,}" apkmname="${apkmname// /-}" apkmname="${apkmname//[^a-z0-9-]/}"
url="${url}/${apkmname}-${version//./-}-release/"
resp=$(req "$url" -) || return 1
node=$($HTMLQ "div.table-row.headerFont:nth-last-child(1)" -r "span:nth-child(n+3)" <<<"$resp")
if [ "$node" ]; then
if ! dlurl=$(apk_mirror_search "$resp" "$dpi" "${arch}" "APK"); then
if ! dlurl=$(apk_mirror_search "$resp" "$dpi" "${arch}" "BUNDLE"); then
return 1
else is_bundle=true; fi
fi
for current_dpi in $dpi; do
for type in APK BUNDLE; do
if dlurl=$(apkmirror_search "$resp" "$current_dpi" "${arch}" "$type"); then
[[ "$type" == "BUNDLE" ]] && is_bundle=true || is_bundle=false
break 2
fi
done
done
[ -z "$dlurl" ] && return 1
resp=$(req "$dlurl" -)
fi
@@ -381,14 +426,14 @@ get_apkmirror_vers() {
}
get_apkmirror_pkg_name() { sed -n 's;.*id=\(.*\)" class="accent_color.*;\1;p' <<<"$__APKMIRROR_RESP__"; }
get_apkmirror_resp() {
__APKMIRROR_RESP__=$(req "${1}" -)
__APKMIRROR_RESP__=$(req "${1}" -) || return 1
__APKMIRROR_CAT__="${1##*/}"
}
# -------------------- uptodown --------------------
get_uptodown_resp() {
__UPTODOWN_RESP__=$(req "${1}/versions" -)
__UPTODOWN_RESP_PKG__=$(req "${1}/download" -)
__UPTODOWN_RESP__=$(req "${1}/versions" -) || return 1
__UPTODOWN_RESP_PKG__=$(req "${1}/download" -) || return 1
}
get_uptodown_vers() { $HTMLQ --text ".version" <<<"$__UPTODOWN_RESP__"; }
dl_uptodown() {
@@ -396,14 +441,14 @@ dl_uptodown() {
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
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_64' '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 is_bundle=false
for i in {1..5}; do
for i in {1..20}; do
resp=$(req "${uptodown_dlurl}/apps/${data_code}/versions/${i}" -)
if ! op=$(jq -e -r ".data | map(select(.version == \"${version}\")) | .[0]" <<<"$resp"); then
continue
@@ -412,20 +457,30 @@ dl_uptodown() {
if versionURL=$(jq -e -r '.versionURL' <<<"$op"); then break; else return 1; fi
done
if [ -z "$versionURL" ]; then return 1; fi
versionURL=$(jq -e -r '.url + "/" + .extraURL + "/" + (.versionID | tostring)' <<<"$versionURL")
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
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 ! 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}-x" -)
break
done
if [ "$data_version" ]; then
files=$(req "${uptodown_dlurl%/*}/app/${data_code}/version/${data_version}/files" - | jq -e -r .content) || return 1
for ((n = 1; n < 12; n += 1)); do
node_class=$($HTMLQ -w -t ".content > :nth-child($n)" --attribute class <<<"$files") || return 1
if [ "$node_class" != "variant" ]; then
node_arch=$($HTMLQ -w -t ".content > :nth-child($n)" <<<"$files" | xargs) || return 1
continue
fi
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
data_url=$($HTMLQ "#detail-download-button" --attribute data-url <<<"$resp") || return 1
if [ $is_bundle = true ]; then
@@ -446,7 +501,7 @@ dl_archive() {
}
get_archive_resp() {
local r
r=$(req "$1" -)
r=$(req "$1" -) || return 1
if [ -z "$r" ]; then return 1; else __ARCHIVE_RESP__=$(sed -n 's;^<a href="\(.*\)"[^"]*;\1;p' <<<"$r"); fi
__ARCHIVE_PKG_NAME__=$(awk -F/ '{print $NF}' <<<"$1")
}
@@ -506,7 +561,7 @@ build_rv() {
local tried_dl=()
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
if ! get_${dl_p}_resp "${args[${dl_p}_dlurl]}" || ! pkg_name=$(get_"${dl_p}"_pkg_name) || [ -z "$pkg_name" ]; then
args[${dl_p}_dlurl]=""
epr "ERROR: Could not find ${table} in ${dl_p}"
continue
@@ -520,7 +575,7 @@ build_rv() {
return 0
fi
local list_patches
list_patches=$(java -jar "$rv_cli_jar" list-patches "$rv_patches_jar" -f "$pkg_name" -v -p 2>&1)
list_patches=$(patches_list "$rv_cli_jar" "$rv_patches_jar" "$pkg_name") || return 1
local get_latest_ver=false
if [ "$version_mode" = auto ]; then
@@ -561,7 +616,7 @@ build_rv() {
for dl_p in archive apkmirror uptodown; do
if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi
pr "Downloading '${table}' from ${dl_p}"
if ! isoneof $dl_p "${tried_dl[@]}"; then get_${dl_p}_resp "${args[${dl_p}_dlurl]}"; fi
if ! isoneof $dl_p "${tried_dl[@]}"; then get_${dl_p}_resp "${args[${dl_p}_dlurl]}" || true; fi
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