|
1 | 1 | #!/usr/bin/bash |
2 | 2 |
|
3 | 3 | 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) |
6 | 6 |
|
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 |
12 | 12 |
|
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" ' |
22 | 20 | ( |
23 | 21 | $AVAILABLE_PATCHES[] | |
24 | 22 | select(.pkgName == $PKG_NAME) | |
25 | | - .versions | debug |
| 23 | + .versions |
26 | 24 | ) as $SUPPORTED_VERSIONS | |
27 | 25 | [ |
28 | 26 | .[].children | |
@@ -73,33 +71,33 @@ scrapeVersionsList() { |
73 | 71 | ) |
74 | 72 | ) |
75 | 73 | ' |
76 | | - ) |
| 74 | + ) |
77 | 75 | } |
78 | 76 |
|
79 | 77 | 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') |
105 | 103 | } |
0 commit comments