Skip to content
This repository was archived by the owner on Dec 6, 2025. It is now read-only.

Commit ed1bfe0

Browse files
committed
refactor: rename module
1 parent 8dc75cf commit ed1bfe0

2 files changed

Lines changed: 41 additions & 43 deletions

File tree

modules/app/version.sh

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
#!/usr/bin/bash
22

33
scrapeVersionsList() {
4-
local PAGE VERSIONS
5-
PAGE=$("${CURL[@]}" -A "$USER_AGENT" "https://www.apkmirror.com/uploads/?appcategory=$APKMIRROR_APP_NAME" 2>&1)
4+
local PAGE VERSIONS
5+
PAGE=$("${CURL[@]}" -A "$USER_AGENT" "https://www.apkmirror.com/uploads/?appcategory=$APKMIRROR_APP_NAME" 2>&1)
66

7-
if [ "$PAGE" == "" ]; then
8-
notify msg "Unable to fetch versions !!\nThere is some problem with your internet connection. Disable VPN or Change your network."
9-
TASK="CHOOSE_APP"
10-
return 1
11-
fi
7+
if [ "$PAGE" == "" ]; then
8+
notify msg "Unable to fetch versions !!\nThere is some problem with your internet connection. Disable VPN or Change your network."
9+
TASK="CHOOSE_APP"
10+
return 1
11+
fi
1212

13-
pup -c 'div.widget_appmanager_recentpostswidget div.listWidget div:not([class]) json{}' <<<"$PAGE" >page.json
14-
15-
readarray -t VERSIONS_LIST < <(
16-
pup -c 'div.widget_appmanager_recentpostswidget div.listWidget div:not([class]) json{}' <<<"$PAGE" |
17-
jq -rc \
18-
--arg PKG_NAME "$PKG_NAME" \
19-
--arg INSTALLED_VERSION "$INSTALLED_VERSION" \
20-
--arg ALLOW_APP_VERSION_DOWNGRADE "$ALLOW_APP_VERSION_DOWNGRADE" \
21-
--argjson AVAILABLE_PATCHES "$AVAILABLE_PATCHES" '
13+
readarray -t VERSIONS_LIST < <(
14+
pup -c 'div.widget_appmanager_recentpostswidget div.listWidget div:not([class]) json{}' <<<"$PAGE" |
15+
jq -rc \
16+
--arg PKG_NAME "$PKG_NAME" \
17+
--arg INSTALLED_VERSION "$INSTALLED_VERSION" \
18+
--arg ALLOW_APP_VERSION_DOWNGRADE "$ALLOW_APP_VERSION_DOWNGRADE" \
19+
--argjson AVAILABLE_PATCHES "$AVAILABLE_PATCHES" '
2220
(
2321
$AVAILABLE_PATCHES[] |
2422
select(.pkgName == $PKG_NAME) |
25-
.versions | debug
23+
.versions
2624
) as $SUPPORTED_VERSIONS |
2725
[
2826
.[].children |
@@ -73,33 +71,33 @@ scrapeVersionsList() {
7371
)
7472
)
7573
'
76-
)
74+
)
7775
}
7876

7977
chooseVersion() {
80-
unset APP_VER APP_DL_URL
81-
local INSTALLED_VERSION SELECTED_VERSION
82-
internet || return 1
83-
getInstalledVersion
84-
if [ "${#VERSIONS_LIST[@]}" -eq 0 ]; then
85-
notify info "Please Wait !!\nScraping versions list for $APP_NAME from apkmirror.com..."
86-
scrapeVersionsList || return 1
87-
fi
88-
if ! SELECTED_VERSION=$(
89-
"${DIALOG[@]}" \
90-
--title '| Version Selection Menu |' \
91-
--no-tags \
92-
--column-separator "|" \
93-
--default-item "$SELECTED_VERSION" \
94-
--ok-label 'Select' \
95-
--cancel-label 'Back' \
96-
--menu "$NAVIGATION_HINT" -1 -1 0 \
97-
"${VERSIONS_LIST[@]}" \
98-
2>&1 >/dev/tty
99-
); then
100-
TASK="CHOOSE_APP"
101-
return 1
102-
fi
103-
APP_VER=$(jq -nrc --argjson SELECTED_VERSION "$SELECTED_VERSION" '$SELECTED_VERSION.version | sub(" "; ""; "g")')
104-
APP_DL_URL=$(jq -nrc --argjson SELECTED_VERSION "$SELECTED_VERSION" '"https://www.apkmirror.com" + $SELECTED_VERSION.url')
78+
unset APP_VER APP_DL_URL
79+
local INSTALLED_VERSION SELECTED_VERSION
80+
internet || return 1
81+
getInstalledVersion
82+
if [ "${#VERSIONS_LIST[@]}" -eq 0 ]; then
83+
notify info "Please Wait !!\nScraping versions list for $APP_NAME from apkmirror.com..."
84+
scrapeVersionsList || return 1
85+
fi
86+
if ! SELECTED_VERSION=$(
87+
"${DIALOG[@]}" \
88+
--title '| Version Selection Menu |' \
89+
--no-tags \
90+
--column-separator "|" \
91+
--default-item "$SELECTED_VERSION" \
92+
--ok-label 'Select' \
93+
--cancel-label 'Back' \
94+
--menu "$NAVIGATION_HINT" -1 -1 0 \
95+
"${VERSIONS_LIST[@]}" \
96+
2>&1 >/dev/tty
97+
); then
98+
TASK="CHOOSE_APP"
99+
return 1
100+
fi
101+
APP_VER=$(jq -nrc --argjson SELECTED_VERSION "$SELECTED_VERSION" '$SELECTED_VERSION.version | sub(" "; ""; "g")')
102+
APP_DL_URL=$(jq -nrc --argjson SELECTED_VERSION "$SELECTED_VERSION" '"https://www.apkmirror.com" + $SELECTED_VERSION.url')
105103
}

0 commit comments

Comments
 (0)