1
0
Fork 0
mirror of https://github.com/aclist/dztui.git synced 2024-12-28 05:12:36 +01:00

Split response into two variables

This commit is contained in:
aclist 2022-08-12 09:52:07 +09:00
parent b664fb70d0
commit c8c0bfbce4
2 changed files with 13 additions and 10 deletions

View file

@ -4,6 +4,10 @@
- Clean up logging
- Custom query API
## [2.4.2-rc.2] 2022-08-10
### Fixed
- Pass correct query ports to modlist function
## [2.4.2-rc.1] 2022-08-10
### Fixed
- Page though API results to list >10 servers

View file

@ -1,7 +1,7 @@
#!/bin/bash
set -o pipefail
version=2.4.2-rc.1
version=2.4.2-rc.2
aid=221100
game="dayz"
workshop="steam://url/CommunityFilePage/"
@ -80,9 +80,6 @@ items=(
"View changelog"
)
}
cleanup(){
rm $tmp
}
warn_and_exit(){
zenity --info --title="DZGUI" --text="$1" --icon-name="dialog-warning" 2>/dev/null
printf "[DZGUI] %s\n" "$check_config_msg"
@ -97,6 +94,7 @@ info(){
set_api_params(){
response=$(curl -s "$api" -H "Authorization: Bearer "$api_key"" -G -d "sort=-players" \
-d "filter[game]=$game" -d "filter[ids][whitelist]=$list_of_ids")
list_response=$response
}
query_api(){
#TODO: prevent drawing list if null values returned without API error
@ -377,7 +375,7 @@ connect(){
#TODO: sanitize/validate input
readarray -t qport_arr <<< "$qport_list"
if [[ -z ${qport_arr[@]} ]]; then
err "Failed to process favorite server"
err "Failed to obtain query ports"
return
fi
ip=$(echo "$1" | awk -F"$separator" '{print $1}')
@ -700,15 +698,15 @@ main_menu(){
done
}
page_through(){
response=$(curl -s "$page")
list=$(echo "$response" | jq -r '.data[] .attributes | "\(.name)\t\(.ip):\(.port)\t\(.players)/\(.maxPlayers)\t\(.details.time)\t\(.status)\t\(.id)"')
list_response=$(curl -s "$page")
list=$(echo "$list_response" | jq -r '.data[] .attributes | "\(.name)\t\(.ip):\(.port)\t\(.players)/\(.maxPlayers)\t\(.details.time)\t\(.status)\t\(.id)"')
idarr+=("$list")
parse_json
}
parse_json(){
page=$(echo "$response" | jq -r '.links.next?')
page=$(echo "$list_response" | jq -r '.links.next?')
if [[ "$page" != "null" ]]; then
list=$(echo "$response" | jq -r '.data[] .attributes | "\(.name)\t\(.ip):\(.port)\t\(.players)/\(.maxPlayers)\t\(.details.time)\t\(.status)\t\(.id)"')
list=$(echo "$list_response" | jq -r '.data[] .attributes | "\(.name)\t\(.ip):\(.port)\t\(.players)/\(.maxPlayers)\t\(.details.time)\t\(.status)\t\(.id)"')
idarr+=("$list")
page_through
else
@ -763,6 +761,7 @@ create_array(){
}
set_fav(){
#TODO: test API key here and return errors
echo "[DZGUI] Querying favorite server"
query_api
fav_label=$(curl -s "$api" -H "Authorization: Bearer "$api_key"" -G -d "filter[game]=$game" -d "filter[ids][whitelist]=$fav" \
| jq -r '.data[] .attributes .name')
@ -956,4 +955,4 @@ main(){
}
main
trap cleanup EXIT
#trap cleanup EXIT