Merge pull request #4231 from Gemba/skyscraper_enhance_options

skyscraper: enhance options



    Prompt user to clear/keep platform selection after gamelist creation
    Add menuoption to bypass all flags applied by this scriptmodule (or its config) to Skyscraper
    Fix default selection by entering/leaving submenus
    The return codes between the scriptmodule and Skyscraper were still not matching. Now they are: 0 Skyscraper success, 1+2 Skyscraper error, 3 user ctrl-c (module and Skyscraper), 4 scraping did not start (module only return value)
This commit is contained in:
Cristi Mitrana
2026-10-06 18:51:49 +03:00
committed by GitHub
+371 -302
View File
@@ -70,7 +70,6 @@ function install_skyscraper() {
md_ret_files+=("${config_files[@]}")
}
function _config_files_skyscraper() {
local config_files=(
'aliasMap.csv'
@@ -162,14 +161,14 @@ function _purge_platform_skyscraper() {
# If not folders are found, show an info message instead of the selection list
if [[ ${#options[@]} -eq 0 ]]; then
printMsgs "dialog" "Nothing to delete ! No cached platforms found in \n$configdir/all/skyscraper/$cache_folder."
printMsgs "dialog" "Nothing to delete! No cached platforms found in \n$configdir/all/skyscraper/$cache_folder."
return
fi
local mode="$1"
[[ -z "$mode" ]] && mode="purge"
local cmd=(dialog --backtitle "$__backtitle" --radiolist "Select platform to $mode" 20 60 12)
local cmd=(dialog --backtitle "$__backtitle" --radiolist "Select platform cache to $mode" 20 60 12)
local platform=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
# Exit if no platform chosen
@@ -336,33 +335,6 @@ function _get_clioptions_skyscraper() {
[[ "$system" != "<platform>" ]] && system=\"$system\"
params+=(-p "$system")
flags="unattend,skipped,nohints,"
[[ "$download_videos" -eq 1 ]] && flags+="videos,"
[[ "$cache_marquees" -eq 0 ]] && flags+="nomarquees,"
[[ "$cache_covers" -eq 0 ]] && flags+="nocovers,"
[[ "$cache_screenshots" -eq 0 ]] && flags+="noscreenshots,"
[[ "$cache_wheels" -eq 0 ]] && flags+="nowheels,"
[[ "$only_missing" -eq 1 ]] && flags+="onlymissing,"
[[ "$rom_name" -eq 1 ]] && flags+="forcefilename,"
[[ "$remove_brackets" -eq 1 ]] && flags+="nobrackets,"
if [[ "$use_rom_folder" -eq 1 ]]; then
params+=(-g "$romdir/$system")
params+=(-o "$romdir/$system/media")
# If we're saving to the ROM folder, then use relative paths in the gamelist
flags+="relative,"
else
params+=(-g "$home/.emulationstation/gamelists/$system")
params+=(-o "$home/.emulationstation/downloaded_media/$system")
fi
# If 2nd parameter is unset, use the configured scraping source, otherwise scrape from cache.
# Scraping from cache means we can omit '-s' from the parameter list.
@@ -370,32 +342,52 @@ function _get_clioptions_skyscraper() {
params+=(-s "$scrape_source")
fi
if [[ "$bypass_all_flags" -eq 0 ]]; then
flags="unattend,skipped,nohints,"
[[ "$download_videos" -eq 1 ]] && flags+="videos,"
[[ "$cache_marquees" -eq 0 ]] && flags+="nomarquees,"
[[ "$cache_covers" -eq 0 ]] && flags+="nocovers,"
[[ "$cache_screenshots" -eq 0 ]] && flags+="noscreenshots,"
[[ "$cache_wheels" -eq 0 ]] && flags+="nowheels,"
[[ "$only_missing" -eq 1 ]] && flags+="onlymissing,"
[[ "$rom_name" -eq 1 ]] && flags+="forcefilename,"
[[ "$remove_brackets" -eq 1 ]] && flags+="nobrackets,"
if [[ "$use_rom_folder" -eq 1 ]]; then
params+=(-g "$romdir/$system")
params+=(-o "$romdir/$system/media")
# If we're saving to the ROM folder, then use relative paths in the gamelist
flags+="relative,"
else
params+=(-g "$home/.emulationstation/gamelists/$system")
params+=(-o "$home/.emulationstation/downloaded_media/$system")
fi
# There will always be a ',' at the end of $flags, so let's remove it
flags=${flags::-1}
params+=(--flags "$flags")
fi
[[ "$force_refresh" -eq 1 ]] && params+=(--refresh)
# There will always be a ',' at the end of $flags, so let's remove it
flags=${flags::-1}
params+=(--flags "$flags")
echo -n "${params[@]}"
}
# Scrape one system, passed as parameter
function _scrape_skyscraper() {
local system="$1"
local scrape_module="$2"
[[ -z "$system" ]] && return 3
[[ -z "$system" ]] && return 4
local params
params=$(_get_clioptions_skyscraper "$system" "$scrape_module")
declare -a "params_arr=($params)"
sudo -u "$__user" stdbuf -o0 "$md_inst/Skyscraper" "${params_arr[@]}";
sudo -u "$__user" stdbuf -o0 "$md_inst/Skyscraper" "${params_arr[@]}"
local ret=$?
if [[ $ret -eq 0 ]]; then
# while this message is shown trap ctrl+c and return with 2 (aborted), rather than exiting retropie-setup
trap 'trap 2; return 2' INT
# while this message is shown trap ctrl+c and return with 3 (aborted), rather than exiting retropie-setup
trap 'trap 2; return 3' INT
printMsgs console -e "\nCOMMAND LINE USED:\n$md_inst/Skyscraper ${params}"
sleep 2
trap 2
@@ -406,7 +398,7 @@ function _scrape_skyscraper() {
# Scrape a list of systems, chosen by the user
function _scrape_chosen_skyscraper() {
! _check_ver_skyscraper && return 3
! _check_ver_skyscraper && return 4
local options=()
local system
@@ -422,9 +414,9 @@ function _scrape_chosen_skyscraper() {
options+=("$system" "$system" "$sel")
done < <(_list_systems_skyscraper)
if [[ ${#options[@]} -eq 0 ]] ; then
if [[ ${#options[@]} -eq 0 ]]; then
printMsgs "dialog" "No populated ROM folders in $romdir and no configured EmulationStation systems were found."
return 3
return 4
fi
local choices
@@ -433,7 +425,7 @@ function _scrape_chosen_skyscraper() {
choices=($("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty))
# Exit if nothing was chosen or Cancel was used
[[ ${#choices[@]} -eq 0 || $? -eq 1 ]] && return 3
[[ ${#choices[@]} -eq 0 || $? -eq 1 ]] && return 4
_skyscraper_platform_choices=("${choices[@]}")
# Confirm with the user that scraping can start
@@ -448,7 +440,7 @@ function _scrape_chosen_skyscraper() {
msg+="For each selected <platform> Skyscraper is run with these commandline options:\n\n$sky_cmd"
if ! dialog --clear --colors --yes-label "Proceed" --no-label "Abort" --yesno "$msg" 20 70 >/dev/tty 2>&1; then
return 3
return 4
fi
local choice
@@ -463,7 +455,7 @@ function _scrape_chosen_skyscraper() {
# Generate gamelists for a list of systems, chosen by the user
function _generate_chosen_skyscraper() {
! _check_ver_skyscraper && return 3
! _check_ver_skyscraper && return 4
local options=()
local system
@@ -479,9 +471,9 @@ function _generate_chosen_skyscraper() {
options+=("$system" "$system" "$sel")
done < <(_list_systems_skyscraper)
if [[ ${#options[@]} -eq 0 ]] ; then
if [[ ${#options[@]} -eq 0 ]]; then
printMsgs "dialog" "No populated ROM folders in $romdir and no configured EmulationStation systems were found."
return 3
return 4
fi
local choices
@@ -490,7 +482,7 @@ function _generate_chosen_skyscraper() {
choices=($("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty))
# Exit if nothing was chosen or Cancel was used
[[ ${#choices[@]} -eq 0 || $? -eq 1 ]] && return 3
[[ ${#choices[@]} -eq 0 || $? -eq 1 ]] && return 4
_skyscraper_platform_choices=("${choices[@]}")
for choice in "${choices[@]}"; do
@@ -500,6 +492,10 @@ function _generate_chosen_skyscraper() {
return $ret
fi
done
# silently clear platform selection
#if dialog --clear --defaultno --colors --yesno "Game list(s) generated.\n\nReset platform selection?" 8 60 2>&1 >/dev/tty; then
_skyscraper_platform_choices=()
#fi
}
function _load_config_skyscraper() {
@@ -514,7 +510,8 @@ function _load_config_skyscraper() {
'scrape_source=screenscraper' \
'remove_brackets=0' \
'force_refresh=0' \
'only_missing=0'
'only_missing=0' \
'bypass_all_flags=0'
}
# Try to guess the most appropriate editor. On Debian derivatives, we have `sensible-editor` for that.
@@ -522,10 +519,10 @@ function _open_editor_skyscraper() {
local editor
if [[ -n $(command -v sensible-editor) ]]; then
sudo -u "$__user" sensible-editor "$1" > /dev/tty < /dev/tty
sudo -u "$__user" sensible-editor "$1" >/dev/tty </dev/tty
else
editor="${EDITOR:-nano}"
sudo -u "$__user" $editor "$1" > /dev/tty < /dev/tty
sudo -u "$__user" $editor "$1" >/dev/tty </dev/tty
fi
}
@@ -536,26 +533,48 @@ function _gui_advanced_skyscraper() {
eval "$(_load_config_skyscraper)"
help_strings_adv=(
[E]="Opens the configuration file \Zbconfig.ini\Zn in an editor."
[F]="Opens the artwork definition file \Zbartwork.xml\Zn in an editor."
[G]="Opens the game alias configuration file \ZbaliasMap.csv\Zn in an editor."
[B]="Controls if flags configured in these dialogs are applied or not.\n\nIf set to \ZbYes\Zn then the flags and the configuration file values do apply, whereas the flags have precedence over the configuration file values.\nIf set to \ZbNo\Zn then the flags from here are not applied and the configuration file values or defaults are used.\n\nThe refresh flag option is available in any case. Also, platform and scraper source selection are always retained."
[E]="Opens the configuration file \Zuconfig.ini\Zn in an editor."
[F]="Opens the artwork definition file \Zuartwork.xml\Zn in an editor."
[G]="Opens the game alias configuration file \ZualiasMap.csv\Zn in an editor."
)
if [[ -e "$configdir/all/skyscraper/peas_local.json" ]]; then
help_strings_adv+=([P]="Opens your platform, extensions and alias definition in an editor.")
fi
if [[ -e "$configdir/all/skyscraper/platforms_idmap_local.csv" ]]; then
help_strings_adv+=([Q]="Opens your platform to scraper web-API system-id mapping in an editor.")
fi
while true; do
local cmd=(dialog --backtitle "$__backtitle" --help-button --colors --no-collapse --default-item "$default" --ok-label "Ok" --cancel-label "Back" --title "Advanced options" --menu " EXPERT - edit configurations\n" 14 50 5)
local cmd=(dialog --backtitle "$__backtitle" --help-button --colors --no-collapse --default-item "$default_adv" --ok-label "Ok" --cancel-label "Back" --title "Advanced options" --menu "Override settings and edit configurations\n" 14 58 5)
local options=()
if [[ "$bypass_all_flags" -eq 1 ]]; then
options+=(B "Use flags: No (only config.ini values apply)")
else
options+=(B "Use flags: Yes (flags and config.ini apply) ")
fi
options+=(E "Edit 'config.ini'")
options+=(F "Edit 'artwork.xml'")
options+=(G "Edit 'aliasMap.csv'")
if [[ -e "$configdir/all/skyscraper/peas_local.json" ]]; then
options+=(P "Edit 'peas_local.json'")
fi
if [[ -e "$configdir/all/skyscraper/platforms_idmap_local.csv" ]]; then
options+=(Q "Edit 'platforms_idmap_local.csv'")
fi
local choice=$("${cmd[@]}" "${options[@]}" 2>&1 > /dev/tty)
local choice=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
if [[ -n "$choice" ]]; then
local default="$choice"
local default_adv="$choice"
case "$choice" in
B)
bypass_all_flags="$((bypass_all_flags ^ 1))"
iniSet "bypass_all_flags" "$bypass_all_flags"
;;
E)
_open_editor_skyscraper "$configdir/all/skyscraper/config.ini"
@@ -569,12 +588,21 @@ function _gui_advanced_skyscraper() {
_open_editor_skyscraper "$configdir/all/skyscraper/aliasMap.csv"
;;
P)
_open_editor_skyscraper "$configdir/all/skyscraper/peas_local.json"
;;
Q)
_open_editor_skyscraper "$configdir/all/skyscraper/platforms_idmap_local.csv"
;;
HELP*)
# Retain choice
default="${choice/HELP /}"
if [[ ! -z "${help_strings_adv[${default}]}" ]]; then
dialog --colors --no-collapse --ok-label "Close" --msgbox "${help_strings_adv[${default}]}" 22 65 >&1
default_adv="${choice/HELP /}"
if [[ ! -z "${help_strings_adv[${default_adv}]}" ]]; then
dialog --colors --no-collapse --ok-label "Close" --msgbox "${help_strings_adv[${default_adv}]}" 15 65 >&1
fi
;;
esac
else
break
@@ -587,220 +615,252 @@ function gui_skyscraper() {
printMsgs "dialog" "This scraper must not be run while EmulationStation is running or the scraped data will be overwritten.\n\nPlease quit EmulationStation and run RetroPie-Setup from the terminal:\n\n sudo \$HOME/RetroPie-Setup/retropie_setup.sh"
return
fi
local refresh_main=1
while [[ $refresh_main == 1 ]]; do
refresh_main=0
iniConfig " = " '"' "$configdir/all/skyscraper.cfg"
eval "$(_load_config_skyscraper)"
chown "$__user":"$__group" "$configdir/all/skyscraper.cfg"
iniConfig " = " '"' "$configdir/all/skyscraper.cfg"
eval "$(_load_config_skyscraper)"
chown "$__user":"$__group" "$configdir/all/skyscraper.cfg"
local -a s_source
local -a s_source_names
declare -A help_strings
local -a s_source
local -a s_source_names
declare -A help_strings
s_source=(
[1]=screenscraper
[2]=arcadedb
[3]=thegamesdb
[4]=mobygames
[5]=openretro
[6]=igdb
[7]=zxinfo
)
s_source+=(
[10]=esgamelist
[11]=import
[12]=gamebase
)
s_source=(
[1]=screenscraper
[2]=arcadedb
[3]=thegamesdb
[4]=mobygames
[5]=openretro
[6]=igdb
[7]=zxinfo
)
s_source+=(
[10]=esgamelist
[11]=import
[12]=gamebase
)
s_source_names=(
[1]=ScreenScraper
[2]="Arcade DB"
[3]="TheGames DB"
[4]=MobyGames
[5]=OpenRetro
[6]="Internet Game Database"
[7]="ZX-Info"
)
s_source_names+=(
[10]="EmulationStation Gamelist"
[11]="Import Folder (see docs)"
[12]="Gamebase DB file (see docs)"
)
s_source_names=(
[1]=ScreenScraper
[2]="Arcade DB"
[3]="TheGames DB"
[4]=MobyGames
[5]=OpenRetro
[6]="Internet Game Database"
[7]="ZX-Info"
)
s_source_names+=(
[10]="EmulationStation Gamelist"
[11]="Import Folder (see docs)"
[12]="GameBase DB file (see docs)"
)
local ver
local lastest_ver
local ver
local lastest_ver
# Help strings for this GUI
help_strings=(
[1]="Gather resources and cache them for the platforms found in \Zb$romdir\Zn.\nRuns the scraper to download the information and media from the selected gathering source."
[2]="Select the source for ROM scraping. Supported sources:\n\ZbONLINE\Zn\n * ScreenScraper (screenscraper.fr)\n * TheGamesDB (thegamesdb.net)\n * OpenRetro (openretro.org)\n * ArcadeDB (adb.arcadeitalia.net)\n * ZX-Info (zxinfo.dk)\n\ZbLOCAL\Zn\n * EmulationStation Gamelist (imports data from ES gamelist)\n * GameBase (gather from local SQL file, see bu22.com)\n * Import (imports resources in the local cache)\n\n\Zb\ZrNOTE\Zn: Some sources require a username and password for access. These can be set per source in the \Zbconfig.ini\Zn configuration file.\n\n Skyscraper parameter: \Zb-s <source_name>\Zn"
[3]="Options for resource gathering and caching sub-menu.\nClick to open it."
[4]="Generate EmulationStation game lists.\nRuns the scraper to incorporate downloaded information and media from the local cache and write them to \Zbgamelist.xml\Zn files to be used by EmulationStation."
[5]="Options for EmulationStation game list generation sub-menu.\nClick to open it and change the options."
[V]="Toggle the download and caching of videos.\nThis also toggles whether the videos will be included in the resulting gamelist.\n\nSkyscraper option: \Zb--flags videos\Zn"
[A]="Advanced options sub-menu."
[U]="Check for an update to Skyscraper."
)
# Help strings for this GUI
local scrapers1=(
"ArcadeDB (adb.arcadeitalia.net)\n"
"Internet Game Database (igdb.com)\n"
"MobyGames (mobygames.com)\n"
"OpenRetro (openretro.org)\n"
"ScreenScraper (screenscraper.fr)\n"
"TheGamesDB (thegamesdb.net)\n"
)
local scrapers2=(
"EmulationStation Gamelist (imports data from ES gamelist)\n"
"GameBase (gather from local SQL file, see bu22.com)\n"
"Import (imports resources from local files)\n"
)
help_strings=(
[1]="Gather resources and cache them for the platforms found in \Zb$romdir\Zn.\nRuns the scraper to download the information and media from the selected gathering source."
[2]="Select the source for ROM scraping. Supported sources:\n\ZbONLINE\Zn\n$(printf " * %s" "${scrapers1[@]}")\ZbLOCAL\Zn\n$(printf " * %s" "${scrapers2[@]}")\n\Zb\ZrNOTE\Zn: Some sources require a username and password for access. These can be set per source in the \Zbconfig.ini\Zn configuration file.\n\nSkyscraper parameter: \Zb-s <source_name>\Zn"
[3]="Options for resource gathering and caching sub-menu."
[4]="Generate EmulationStation game lists.\nRuns the scraper to incorporate downloaded information and media from the local cache and write them to \Zbgamelist.xml\Zn files to be used by EmulationStation."
[5]="Options for EmulationStation game list generation sub-menu."
)
if [[ "$bypass_all_flags" -eq 0 ]]; then
help_strings+=(
[V]="Toggle the download and caching of videos.\n\nThis setting also defines whether the videos will be included in the resulting gamelist.\n\nSkyscraper option: \Zb--flags videos\Zn"
)
fi
help_strings+=(
[A]="Advanced options sub-menu. Here be dragons."
[U]="Check for an update to Skyscraper."
)
ver=$(_get_ver_skyscraper)
while true; do
ver=$(_get_ver_skyscraper)
[[ -z "$ver" ]] && ver="(Git)"
local cmd=(dialog --backtitle "$__backtitle" --colors --cancel-label "Exit" --help-button --no-collapse --cr-wrap --default-item "$default" --menu "Skyscraper: Game Scraper for EmulationStation (v$ver)\\n \\n" 22 60 12)
while true; do
local cmd=(dialog --backtitle "$__backtitle" --colors --cancel-label "Exit" --help-button --no-collapse --cr-wrap --default-item "$default_main" --menu "Skyscraper: Game Scraper for EmulationStation (v$ver)" 22 60 12)
local options=(
" " "---- Gathering and Caching Resources ----"
)
local options=(
" " "---- Gathering and Caching Resources ----"
)
local source_found=0
local online="Online"
local i
local source_found=0
local online="Online"
local i
options+=(
1 "Gather resources"
)
options+=(
1 "Gather resources"
)
for i in "${!s_source[@]}"; do
if [[ "$scrape_source" == "${s_source[$i]}" ]]; then
[[ $i -ge 10 ]] && online="Local"
options+=(2 "Gather source is ${s_source_names[$i]} ($online) --->")
source_found=1
for i in "${!s_source[@]}"; do
if [[ "$scrape_source" == "${s_source[$i]}" ]]; then
[[ $i -ge 10 ]] && online="Local"
options+=(2 "Gather source is ${s_source_names[$i]} ($online) --->")
source_found=1
fi
done
if [[ $source_found -ne 1 ]]; then
options+=(2 "Gather from - Screenscraper (Online) --->")
scrape_source="screenscraper" # default scraping source if none found
iniSet "scrape_source" "$scrape_source"
fi
done
if [[ $source_found -ne 1 ]]; then
options+=(2 "Gather from - Screenscraper (Online) --->")
scrape_source="screenscraper" # default scraping source if none found
iniSet "scrape_source" "$scrape_source"
fi
options+=(3 "Cache options and commands --->")
options+=(3 "Cache options and commands --->")
options+=(" " "---- Creating Game Lists ----")
options+=(4 "Generate game list(s)")
if [[ "$bypass_all_flags" -eq 0 ]]; then
options+=(5 "Generate options --->")
fi
options+=(" " "---- Miscellaneous Options ----")
options+=(" " "---- Creating Game Lists ----")
options+=(4 "Generate game list(s)")
options+=(5 "Generate options --->")
if [[ "$bypass_all_flags" -eq 0 ]]; then
if [[ "$download_videos" -eq 1 ]]; then
options+=(V "Download videos (Enabled)")
else
options+=(V "Download videos (Disabled)")
fi
fi
options+=(" " "---- Miscellaneous Options ----")
options+=(A "Advanced options --->")
options+=(U "Check for Updates")
if [[ "$download_videos" -eq 1 ]]; then
options+=(V "Download videos (Enabled)")
else
options+=(V "Download videos (Disabled)")
fi
# Run the GUI
local choice=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
options+=(A "Advanced options --->")
if [[ -n "$choice" ]]; then
local default_main="$choice"
options+=(U "Check for Updates")
case "$choice" in
# Run the GUI
local choice=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
1)
# return codes:
# 0 : success
# 1,2 : some error
# 3 : user Ctrl-C
# 4 : some condition (dialog shown in callee) or cancel selected
# do not show any dialog here
_scrape_chosen_skyscraper
local ret=$?
if [[ $ret -eq 0 ]]; then
printMsgs "dialog" "ROMs information gathered.\n\nDon't forget to use 'Generate Game list(s)' to add this information to EmulationStation."
elif [[ $ret -eq 1 || $ret -eq 2 ]]; then
printMsgs "dialog" "Gathering had errors!"
elif [[ $ret -eq 3 ]]; then
printMsgs "dialog" "Gathering was aborted."
fi
;;
if [[ -n "$choice" ]]; then
local default="$choice"
2)
# Scrape source options have a separate dialog
local s_options=()
local i
case "$choice" in
for i in "${!s_source[@]}"; do
online="Online:"
[[ i -ge 10 ]] && online="Local:"
1)
_scrape_chosen_skyscraper
local ret=$?
if [[ $ret -eq 0 ]]; then
printMsgs "dialog" "ROMs information gathered.\n\nDon't forget to use 'Generate Game list(s)' to add this information to EmulationStation."
elif [[ $ret -eq 1 ]]; then
printMsgs "dialog" "Gathering had errors!"
elif [[ $ret -eq 2 ]]; then
printMsgs "dialog" "Gathering was aborted."
fi
;;
if [[ "$scrape_source" == "${s_source[$i]}" ]]; then
s_default="$online ${s_source_names[$i]}"
fi
2)
# Scrape source options have a separate dialog
local s_options=()
local i
s_options+=("$online ${s_source_names[$i]}" "")
done
for i in "${!s_source[@]}"; do
online="Online:"
[[ i -ge 10 ]] && online="Local:"
if [[ "$scrape_source" == "${s_source[$i]}" ]]; then
s_default="$online ${s_source_names[$i]}"
if [[ -z "$s_default" ]]; then
s_default="Online: ${s_source_names[1]}"
fi
s_options+=("$online ${s_source_names[$i]}" "")
done
local s_cmd=(dialog --title "Select Scraping source" --default-item "$s_default" \
--menu "Choose one of the available scraping sources" 18 50 9)
if [[ -z "$s_default" ]]; then
s_default="Online: ${s_source_names[1]}"
fi
# Run the Scraper source selection dialog
local scrape_source_name=$("${s_cmd[@]}" "${s_options[@]}" 2>&1 >/dev/tty)
local s_cmd=(dialog --title "Select Scraping source" --default-item "$s_default" \
--menu "Choose one of the available scraping sources" 18 50 9)
# If Cancel was chosen, don't do anything
[[ -z "$scrape_source_name" ]] && continue
# Run the Scraper source selection dialog
local scrape_source_name=$("${s_cmd[@]}" "${s_options[@]}" 2>&1 >/dev/tty)
# Strip the "XYZ:" prefix from the chosen scraper source, then compare to our list
local src=$(echo "$scrape_source_name" | cut -d' ' -f2-)
# If Cancel was chosen, don't do anything
[[ -z "$scrape_source_name" ]] && continue
for i in "${!s_source_names[@]}"; do
[[ "${s_source_names[$i]}" == "$src" ]] && scrape_source=${s_source[$i]}
done
# Strip the "XYZ:" prefix from the chosen scraper source, then compare to our list
local src=$(echo "$scrape_source_name" | cut -d' ' -f2-)
iniSet "scrape_source" "$scrape_source"
;;
for i in "${!s_source_names[@]}"; do
[[ "${s_source_names[$i]}" == "$src" ]] && scrape_source=${s_source[$i]}
done
3)
_gui_cache_skyscraper
;;
iniSet "scrape_source" "$scrape_source"
;;
4)
_generate_chosen_skyscraper "cache"
local ret=$?
if [[ $ret -eq 1 || $ret -eq 2 ]]; then
printMsgs "dialog" "Game list generation errored!"
elif [[ $ret -eq 3 ]]; then
printMsgs "dialog" "Game list generation aborted."
fi
;;
3)
_gui_cache_skyscraper
;;
5)
_gui_generate_skyscraper
;;
4)
_generate_chosen_skyscraper "cache"
local ret=$?
if [[ $ret -eq 1 ]]; then
printMsgs "dialog" "Game list(s) generated."
elif [[ $ret -eq 1 ]]; then
printMsgs "dialog" "Game list generation errored!"
elif [[ $? -eq 2 ]]; then
printMsgs "dialog" "Game list generation aborted."
fi
;;
V)
download_videos="$((download_videos ^ 1))"
iniSet "download_videos" "$download_videos"
;;
5)
_gui_generate_skyscraper
;;
A)
_gui_advanced_skyscraper
refresh_main=1
break
;;
V)
download_videos="$((download_videos ^ 1))"
iniSet "download_videos" "$download_videos"
;;
U)
local latest_ver="$(_get_branch_skyscraper)"
# check for update
if compareVersions "$latest_ver" gt "$ver" ; then
printMsgs "dialog" "There is a new version available. Latest released version is $latest_ver (You are running $ver).\n\nYou can update the package from:\n\nRetroPie-Setup\n -> Manage Packages\n -> Optional Packages\n -> Section 'RetroPie - supplementary'"
else
printMsgs "dialog" "You are running the latest version ($ver)."
fi
;;
A)
_gui_advanced_skyscraper
;;
U)
local latest_ver="$(_get_branch_skyscraper)"
# check for update
if compareVersions "$latest_ver" gt "$ver" ; then
printMsgs "dialog" "There is a new version available. Latest released version is $latest_ver (You are running $ver).\n\nYou can update the package from RetroPie-Setup -> Manage Packages"
else
printMsgs "dialog" "You are running the latest version ($ver)."
fi
;;
HELP*)
# Retain choice when the Help button is selected
default="${choice/HELP /}"
if [[ ! -z "${help_strings[$default]}" ]]; then
dialog --colors --no-collapse --ok-label "Close" --msgbox "${help_strings[$default]}" 22 65 >&1
fi
;;
esac
else
break
fi
HELP*)
# Retain choice when the Help button is selected
default_main=$(printf "%s" "${choice/HELP /}" | xargs)
if [[ ! -z "$default_main" && ! -z "${help_strings[$default_main]}" ]]; then
dialog --colors --no-collapse --ok-label "Close" --msgbox "${help_strings[$default_main]}" 15 65 >&1
else
dialog --colors --no-collapse --ok-label "Close" --msgbox "No help available." 6 22 >&1
fi
;;
esac
else
break
fi
done
done
}
@@ -812,54 +872,61 @@ function _gui_cache_skyscraper() {
iniConfig " = " '"' "$configdir/all/skyscraper.cfg"
eval "$(_load_config_skyscraper)"
help_strings_cache=(
[1]="Toggle whether screenshots are cached locally when scraping.\n\nSkyscraper option: \Zb--flags noscreenshots\Zn"
[2]="Toggle whether covers are cached locally when scraping.\n\nSkyscraper option: \Zb--flags nocovers\Zn"
[3]="Toggle whether wheels are cached locally when scraping.\n\nSkyscraper option: \Zb--flags nowheels\Zn"
[4]="Toggle whether marquees are cached locally when scraping.\n\nSkyscraper option: \Zb--flags nomarquees\Zn"
[5]="Enable this to only scrape files that do not already have data in the Skyscraper resource cache.\n\nSkyscraper option: \Zb--flags onlymissing\Zn"
if [[ "$bypass_all_flags" -eq 0 ]]; then
help_strings_cache=(
[1]="Toggle whether screenshots are cached locally when scraping.\n\nSkyscraper option: \Zb--flags noscreenshots\Zn"
[2]="Toggle whether covers are cached locally when scraping.\n\nSkyscraper option: \Zb--flags nocovers\Zn"
[3]="Toggle whether wheels are cached locally when scraping.\n\nSkyscraper option: \Zb--flags nowheels\Zn"
[4]="Toggle whether marquees are cached locally when scraping.\n\nSkyscraper option: \Zb--flags nomarquees\Zn"
[5]="Enable this to only scrape files that do not already have data in the Skyscraper resource cache.\n\nSkyscraper option: \Zb--flags onlymissing\Zn")
else
help_strings_cache=()
fi
help_strings_cache+=(
[6]="Force the refresh of resources in the local cache when scraping.\n\nSkyscraper option: \Zb--cache refresh\Zn"
[P]="Purge \ZbALL\Zn all cached resources for all platforms."
[S]="Purge all cached resources for a chosen platform.\n\nSkyscraper option: \Zb--cache purge:all\Zn"
[V]="Removes all non-used cached resources for a chosen platform (vacuum).\n\nSkyscraper option: \Zb--cache vacuum\Zn"
[V]="Removes all non-used cached resources for a chosen platform (vacuum). Non-used means to be not part of the gamelist output.\n\nSkyscraper option: \Zb--cache vacuum -p <platform>\Zn"
[S]="Purge all cached resources for a chosen platform.\n\nSkyscraper option: \Zb--cache purge:all -p <platform>\Zn"
[P]="Purge \ZbALL\Zn cached resources for ALL platforms.\n\nSkyscraper option: \Zb--cache purge:all\Zn"
)
while true; do
db_size=$(du -sh "$configdir/all/skyscraper/$cache_folder" 2>/dev/null | cut -f 1 || echo 0m)
[[ -z "$db_size" ]] && db_size="0Mb"
db_size="$(du -sh "$configdir/all/skyscraper/$cache_folder" 2>/dev/null | cut -f 1 || echo 0M)iB"
[[ -z "$db_size" ]] && db_size="0MiB"
local cmd=(dialog --backtitle "$__backtitle" --help-button --colors --no-collapse --default-item "$default" --ok-label "Ok" --cancel-label "Back" --title "Cache options and commands" --menu "\n Current cache size: $db_size\n\n" 21 60 12)
local cmd=(dialog --backtitle "$__backtitle" --help-button --colors --no-collapse --default-item "$default_cache" --ok-label "Ok" --cancel-label "Back" --title "Cache options and commands" --menu "\n Current cache size: $db_size\n\n" 19 60 12)
local options=(" " "---- Options for Gathering and Caching ----")
if [[ "$cache_screenshots" -eq 1 ]]; then
options+=(1 "Cache screenshots (Enabled)")
else
options+=(1 "Cache screenshots (Disabled)")
fi
if [[ "$bypass_all_flags" -eq 0 ]]; then
if [[ "$cache_screenshots" -eq 1 ]]; then
options+=(1 "Cache screenshots (Enabled)")
else
options+=(1 "Cache screenshots (Disabled)")
fi
if [[ "$cache_covers" -eq 1 ]]; then
options+=(2 "Cache covers (Enabled)")
else
options+=(2 "Cache covers (Disabled)")
fi
if [[ "$cache_covers" -eq 1 ]]; then
options+=(2 "Cache covers (Enabled)")
else
options+=(2 "Cache covers (Disabled)")
fi
if [[ "$cache_wheels" -eq 1 ]]; then
options+=(3 "Cache wheels (Enabled)")
else
options+=(3 "Cache wheels (Disabled)")
fi
if [[ "$cache_wheels" -eq 1 ]]; then
options+=(3 "Cache wheels (Enabled)")
else
options+=(3 "Cache wheels (Disabled)")
fi
if [[ "$cache_marquees" -eq 1 ]]; then
options+=(4 "Cache marquees (Enabled)")
else
options+=(4 "Cache marquees (Disabled)")
fi
if [[ "$cache_marquees" -eq 1 ]]; then
options+=(4 "Cache marquees (Enabled)")
else
options+=(4 "Cache marquees (Disabled)")
fi
if [[ "$only_missing" -eq 1 ]]; then
options+=(5 "Scrape only missing (Enabled)")
else
options+=(5 "Scrape only missing (Disabled)")
if [[ "$only_missing" -eq 1 ]]; then
options+=(5 "Scrape only missing (Enabled)")
else
options+=(5 "Scrape only missing (Disabled)")
fi
fi
if [[ "$force_refresh" -eq 0 ]]; then
@@ -871,12 +938,12 @@ function _gui_cache_skyscraper() {
options+=(" " "---- Cache Cleanup Commands ----")
options+=(V "Vacuum chosen platform")
options+=(S "Purge chosen platform")
options+=(P "Purge all platforms(!)")
options+=(P "Purge all platforms [!]")
local choice=$("${cmd[@]}" "${options[@]}" 2>&1 > /dev/tty)
local choice=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
if [[ -n "$choice" ]]; then
local default="$choice"
local default_cache="$choice"
case "$choice" in
@@ -919,7 +986,7 @@ function _gui_cache_skyscraper() {
;;
P)
dialog --clear --defaultno --colors --yesno "\Z1\ZbAre you sure ?\Zn\nThis will \Zb\ZuERASE\Zn all locally cached scraped resources" 8 60 2>&1 >/dev/tty
dialog --clear --defaultno --colors --yesno "This will \Zb\ZuERASE\Zn all locally cached scraped resources.\n\n\Z1\ZbAre you sure ?\Zn" 8 60 2>&1 >/dev/tty
if [[ $? == 0 ]]; then
_purge_skyscraper
fi
@@ -927,9 +994,11 @@ function _gui_cache_skyscraper() {
HELP*)
# Retain choice
default="${choice/HELP /}"
if [[ ! -z "${help_strings_cache[${default}]}" ]]; then
dialog --colors --no-collapse --ok-label "Close" --msgbox "${help_strings_cache[${default}]}" 22 65 >&1
default_cache=$(printf "%s" "${choice/HELP /}" | xargs)
if [[ ! -z "$default_cache" && ! -z "${help_strings_cache[$default_cache]}" ]]; then
dialog --colors --no-collapse --ok-label "Close" --msgbox "${help_strings_cache[$default_cache]}" 15 65 >&1
else
dialog --colors --no-collapse --ok-label "Close" --msgbox "No help available." 6 22 >&1
fi
esac
else
@@ -945,38 +1014,38 @@ function _gui_generate_skyscraper() {
eval "$(_load_config_skyscraper)"
help_strings_gen=(
[1]="Game name format used in the EmulationStation game list. Available options:\n\n\ZbSource name\Zn: use the name returned by the scraper\n\ZbFilename\Zn: use the filename of the ROM as game name\n\nSkyscraper option: \Zb--flags forcefilename\Z0"
[1]="Game name format used in the EmulationStation game list. Available options:\n\n\ZbSource name\Zn: use the name returned by the scraper source\n\ZbFilename\Zn: use the filename of the ROM as game name\n\nSkyscraper option: \Zb--flags forcefilename\Z0"
[2]="Game name option to remove/keep the text found between '()' and '[]' in the ROMs filename.\n\nSkyscraper option: \Zb--flags nobrackets\Zn"
[3]="Choose to save the generated 'gamelist.xml' and media in the ROMs folder. Supported options:\n\n\ZbEnabled\Zn saves the 'gamelist.xml' in the ROMs folder and the media in the 'media' sub-folder.\n\n\ZbDisabled\Zn saves the 'gamelist.xml' in \Zu\$HOME/.emulationstation/gamelists/<system>\Zn and the media in \Zu\$HOME/.emulationstation/downloaded_media\Zn.\n\n\Zb\ZrNOTE\Zn: changing this option will not automatically copy the 'gamelist.xml' file and the media to the new location or remove the ones in the old location. You must do this manually.\n\nSkyscraper parameters: \Zb-g <gamelist>\Zn / \Zb-o <path>\Zn"
[3]="Choose to save the generated \Zugamelist.xml\Zn and media in the ROMs folder. Supported options:\n\n\ZbEnabled\Zn saves the \Zugamelist.xml\Zn in the ROMs folder and the media in the \Zumedia\Zn sub-folder.\n\n\ZbDisabled\Zn saves the \Zugamelist.xml\Zn in \Zu\$home/.emulationstation/gamelists/<system>\Zn and the media in \Zu\$home/.emulationstation/downloaded_media\Zn.\n\n\Zb\ZrNOTE\Zn: changing this option will not automatically copy the \Zugamelist.xml\Zn file and the media to the new location or remove the ones in the old location. You must do this manually.\n\nSkyscraper parameters: \Zb-g <gamelist>\Zn and \Zb-o <path>\Zn"
)
while true; do
local cmd=(dialog --backtitle "$__backtitle" --help-button --colors --no-collapse --default-item "$default" --ok-label "Ok" --cancel-label "Back" --title "Game list generation options" --menu "\n\n" 13 60 5)
local cmd=(dialog --backtitle "$__backtitle" --help-button --colors --no-collapse --default-item "$default_gen" --ok-label "Ok" --cancel-label "Back" --title "Game list generation options" --menu "\n\n" 13 60 5)
local -a options
if [[ "$bypass_all_flags" -eq 0 ]]; then
if [[ "$rom_name" -eq 0 ]]; then
options=(1 "ROM Names (Source name)")
else
options=(1 "ROM Names (Filename)")
fi
if [[ "$rom_name" -eq 0 ]]; then
options=(1 "ROM Names (Source name)")
else
options=(1 "ROM Names (Filename)")
if [[ "$remove_brackets" -eq 1 ]]; then
options+=(2 "Remove bracket info (Enabled)")
else
options+=(2 "Remove bracket info (Disabled)")
fi
if [[ "$use_rom_folder" -eq 1 ]]; then
options+=(3 "Use ROM folders for game list & media (Enabled)")
else
options+=(3 "Use ROM folders for game list & media (Disabled)")
fi
fi
if [[ "$remove_brackets" -eq 1 ]]; then
options+=(2 "Remove bracket info (Enabled)")
else
options+=(2 "Remove bracket info (Disabled)")
fi
if [[ "$use_rom_folder" -eq 1 ]]; then
options+=(3 "Use ROM folders for game list & media (Enabled)")
else
options+=(3 "Use ROM folders for game list & media (Disabled)")
fi
local choice=$("${cmd[@]}" "${options[@]}" 2>&1 > /dev/tty)
local choice=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
if [[ -n "$choice" ]]; then
local default="$choice"
local default_gen="$choice"
case "$choice" in
@@ -997,9 +1066,9 @@ function _gui_generate_skyscraper() {
HELP*)
# Retain choice
default="${choice/HELP /}"
if [[ ! -z "${help_strings_gen[${default}]}" ]]; then
dialog --colors --no-collapse --ok-label "Close" --msgbox "${help_strings_gen[${default}]}" 22 65 >&1
default_gen="${choice/HELP /}"
if [[ ! -z "${help_strings_gen[${default_gen}]}" ]]; then
dialog --colors --no-collapse --ok-label "Close" --msgbox "${help_strings_gen[${default_gen}]}" 15 65 >&1
fi
esac
else