mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-23 22:45:38 +00:00
CHEEVOS: enhanced script to handle multiple games
This commit is contained in:
parent
2fed0ed61b
commit
4f968d3843
|
@ -6,16 +6,11 @@ API_KEY=""
|
|||
|
||||
# Funzione per ottenere i retroachievements
|
||||
get_achievements() {
|
||||
curl -s "https://retroachievements.org/API/API_GetUserSummary.php?z=$cheevos_username&u=$cheevos_username&y=$API_KEY&g=1&a=2"
|
||||
curl -s "https://retroachievements.org/API/API_GetUserSummary.php?z=$cheevos_username&u=$cheevos_username&y=$API_KEY&g=10&a=2"
|
||||
}
|
||||
|
||||
# Ottieni i dati degli achievements
|
||||
response=$(get_achievements)
|
||||
game_title=$(echo "$response" | jq -r '.RecentAchievements[][].GameTitle')
|
||||
cheevos_badge="https://retroachievements.org/Badge/"$(echo "$response" | jq -r '.RecentAchievements[][].BadgeName')".png"
|
||||
cheevos_title=$(echo "$response" | jq -r '.RecentAchievements[][].Title')
|
||||
cheevos_desc=$(echo "$response" | jq -r '.RecentAchievements[][].Description')
|
||||
|
||||
|
||||
# Verifica che la risposta non sia vuota o null
|
||||
if [ -z "$response" ] || [ "$response" == "null" ]; then
|
||||
|
@ -23,10 +18,25 @@ if [ -z "$response" ] || [ "$response" == "null" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Estrai e formatta i dati per Zenity
|
||||
achievement_list=("<img src=$cheevos_badge>" "$game_title" "$cheevos_title" "$cheevos_desc")
|
||||
game_titles=$(echo "$response" | jq -r '.RecentAchievements[][].GameTitle')
|
||||
cheevos_badges=$(echo "$response" | jq -r '.RecentAchievements[][].BadgeName')
|
||||
#cheevos_badges="https://retroachievements.org/Badge/"$(echo "$response" | jq -r '.RecentAchievements[][].BadgeName')".png"
|
||||
cheevos_titles=$(echo "$response" | jq -r '.RecentAchievements[][].Title')
|
||||
cheevos_descs=$(echo "$response" | jq -r '.RecentAchievements[][].Description')
|
||||
|
||||
IFS=$'\n' read -r -d '' -a game_title_array < <(printf '%s\0' "$game_titles")
|
||||
IFS=$'\n' read -r -d '' -a cheevos_badge_array < <(printf '%s\0' "$cheevos_badges")
|
||||
IFS=$'\n' read -r -d '' -a cheevos_title_array < <(printf '%s\0' "$cheevos_titles")
|
||||
IFS=$'\n' read -r -d '' -a cheevos_desc_array < <(printf '%s\0' "$cheevos_descs")
|
||||
|
||||
# Costruisci l'elenco degli achievement
|
||||
achievement_list=()
|
||||
for i in "${!game_title_array[@]}"; do
|
||||
achievement_list+=("\""https://retroachievements.org/Badge/"${cheevos_badge_array[i]}".png"\"")
|
||||
achievement_list+=("\"${game_title_array[i]}\"")
|
||||
achievement_list+=("\"${cheevos_title_array[i]}\"")
|
||||
achievement_list+=("\"${cheevos_desc_array[i]}\"")
|
||||
done
|
||||
|
||||
# Mostra la lista in una finestra di dialogo Zenity
|
||||
zenity --list \
|
||||
|
|
Loading…
Reference in a new issue