From f0264784a6f52eaf2b8f8841e2123d98001f57d1 Mon Sep 17 00:00:00 2001 From: Sergio Date: Fri, 25 Mar 2022 10:22:32 +0100 Subject: [PATCH] update --- retroarch/create_retroarch_chd_playlist.sh | 312 ++++++++++++++++++ retroarch/create_retroarch_thumbnails.sh | 298 +++++++++++++++++ retroarch/create_retroarch_thumbnails_all.sh | 33 ++ .../rename_retroarch_arcade_thumbnails.sh | 53 +++ 4 files changed, 696 insertions(+) create mode 100755 retroarch/create_retroarch_chd_playlist.sh create mode 100755 retroarch/create_retroarch_thumbnails.sh create mode 100755 retroarch/create_retroarch_thumbnails_all.sh create mode 100755 retroarch/rename_retroarch_arcade_thumbnails.sh diff --git a/retroarch/create_retroarch_chd_playlist.sh b/retroarch/create_retroarch_chd_playlist.sh new file mode 100755 index 0000000..0b8de7c --- /dev/null +++ b/retroarch/create_retroarch_chd_playlist.sh @@ -0,0 +1,312 @@ +#!/bin/bash +function help_message() { + echo "$USAGE" + echo + echo "Where [SYSTEMS] are:" + for WORD in $SYSTEMS; do + echo -e "\t$WORD" + done +} + +readonly USAGE=" +USAGE: +$(basename "$0") [SYSTEM] [ROM_FOLDER] [PLAYLISTS_FOLDER]" + +readonly SYSTEMS="pcenginecd 3do 3ds amiga amstradcpc apple2 arcade arcadia astrocde atari800 atari2600 atari5200 atari7800 atarijaguar atarilynx atarist c16 c64 c128 coco coleco daphne dragon32 dreamcast fba fds gameandwatch gamegear gb gba gbc gc genesis intellivision mame-advmame mame-libretro mame-mame4all mastersystem megacd megadrive msx n64 nds neogeo nes ngp ngpc oric pc pc88 pc98 pcfx pcengine pokemini ports ps2 psp psx saturn scummvm sega32x segacd sg-1000 snes steam ti99 trs-80 vectrex vic20 videopac virtualboy wii wonderswan wonderswancolor x68000 x1 zmachine zx81 zxspectrum" + +# check if there are all the parameters +if [ "$#" -ne 3 ]; then + help_message + exit 0 +fi + +# check if the system parameter is valid +if ! echo "$SYSTEMS" | grep -w "$1" >/dev/null; then + printf "%s\n" "You must enter a valid system name." + help_message + exit 0 +fi + +#readonly SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +readonly SYSTEM="$1" +readonly ROM_FOLDER="$2" +readonly PLAYLISTS_FOLDER="$3" +readonly BASE_PATH="/Users/sergio/Roms/roms.retroachievements.2020/" + +if ! test -d "${ROM_FOLDER}"/"${SYSTEM}"; then + echo "${ROM_FOLDER}"/"${SYSTEM}" does not exists + exit 0 +fi + +case $SYSTEM in + +3do) + readonly PLAYLIST_NAME="" + ;; +3ds) + readonly PLAYLIST_NAME="" + ;; +amiga) + readonly PLAYLIST_NAME="" + ;; +amstradcpc) + readonly PLAYLIST_NAME="" + ;; +apple2) + readonly PLAYLIST_NAME="" + ;; +arcade) + readonly PLAYLIST_NAME="FBNeo - Arcade Games" + ;; +arcadia) + readonly PLAYLIST_NAME="" + ;; +astrocde) + readonly PLAYLIST_NAME="" + ;; +atari800) + readonly PLAYLIST_NAME="" + ;; +atari2600) + readonly PLAYLIST_NAME="Atari - 2600" + ;; +atari5200) + readonly PLAYLIST_NAME="" + ;; +atari7800) + readonly PLAYLIST_NAME="Atari - 7800" + ;; +atarijaguar) + readonly PLAYLIST_NAME="" + ;; +atarilynx) + readonly PLAYLIST_NAME="Atari - Lynx" + ;; +atarist) + readonly PLAYLIST_NAME="" + ;; +c16) + readonly PLAYLIST_NAME="" + ;; +c64) + readonly PLAYLIST_NAME="" + ;; +c128) + readonly PLAYLIST_NAME="" + ;; +coco) + readonly PLAYLIST_NAME="" + ;; +coleco) + readonly PLAYLIST_NAME="Coleco - ColecoVision" + ;; +daphne) + readonly PLAYLIST_NAME="" + ;; +dragon32) + readonly PLAYLIST_NAME="" + ;; +dreamcast) + readonly PLAYLIST_NAME="" + ;; +fba) + readonly PLAYLIST_NAME="" + ;; +fds) + readonly PLAYLIST_NAME="" + ;; +gameandwatch) + readonly PLAYLIST_NAME="" + ;; +gamegear) + readonly PLAYLIST_NAME="Sega - Game Gear" + ;; +gb) + readonly PLAYLIST_NAME="Nintendo - Game Boy" + ;; +gba) + readonly PLAYLIST_NAME="Nintendo - Game Boy Advance" + ;; +gbc) + readonly PLAYLIST_NAME="Nintendo - Game Boy Color" + ;; +gc) + readonly PLAYLIST_NAME="" + ;; +genesis) + readonly PLAYLIST_NAME="" + ;; +intellivision) + readonly PLAYLIST_NAME="" + ;; +mame-advmame) + readonly PLAYLIST_NAME="" + ;; +mame-libretro) + readonly PLAYLIST_NAME="" + ;; +mame-mame4all) + readonly PLAYLIST_NAME="" + ;; +mastersystem) + readonly PLAYLIST_NAME="Sega - Master System - Mark III" + ;; +megacd) + readonly PLAYLIST_NAME="Sega - Mega-CD - Sega CD" + ;; +megadrive) + readonly PLAYLIST_NAME="Sega - Mega Drive - Genesis" + ;; +msx) + readonly PLAYLIST_NAME="Microsoft - MSX" + ;; +msx2) + readonly PLAYLIST_NAME="Microsoft - MSX2" + ;; +n64) + readonly PLAYLIST_NAME="Nintendo - Nintendo 64" + ;; +nds) + readonly PLAYLIST_NAME="Nintendo - Nintendo DS" + ;; +neogeo) + readonly PLAYLIST_NAME="" + ;; +nes) + readonly PLAYLIST_NAME="Nintendo - Nintendo Entertainment System" + ;; +ngp) + readonly PLAYLIST_NAME="SNK - Neo Geo Pocket" + ;; +ngpc) + readonly PLAYLIST_NAME="SNK - Neo Geo Pocket Color" + ;; +oric) + readonly PLAYLIST_NAME="" + ;; +pc) + readonly PLAYLIST_NAME="" + ;; +pc88) + readonly PLAYLIST_NAME="" + ;; +pc98) + readonly PLAYLIST_NAME="" + ;; +pcfx) + readonly PLAYLIST_NAME="" + ;; +pcengine) + readonly PLAYLIST_NAME="NEC - PC Engine - TurboGrafx 16" + ;; +pcenginecd) + readonly PLAYLIST_NAME="NEC - PC Engine CD" + ;; +pokemini) + readonly PLAYLIST_NAME="" + ;; +ports) + readonly PLAYLIST_NAME="" + ;; +ps2) + readonly PLAYLIST_NAME="" + ;; +psp) + readonly PLAYLIST_NAME="" + ;; +psx) + readonly PLAYLIST_NAME="Sony - PlayStation" + ;; +saturn) + readonly PLAYLIST_NAME="" + ;; +scummvm) + readonly PLAYLIST_NAME="" + ;; +sega32x) + readonly PLAYLIST_NAME="" + ;; +segacd) + readonly PLAYLIST_NAME="Sega - Mega-CD - Sega CD" + ;; +sg-1000) + readonly PLAYLIST_NAME="Sega - SG-1000" + ;; +snes) + readonly PLAYLIST_NAME="Nintendo - Super Nintendo Entertainment System" + ;; +steam) + readonly PLAYLIST_NAME="" + ;; +ti99) + readonly PLAYLIST_NAME="" + ;; +trs-80) + readonly PLAYLIST_NAME="" + ;; +vectrex) + readonly PLAYLIST_NAME="" + ;; +vic20) + readonly PLAYLIST_NAME="" + ;; +videopac) + readonly PLAYLIST_NAME="" + ;; +virtualboy) + readonly PLAYLIST_NAME="" + ;; +wii) + readonly PLAYLIST_NAME="" + ;; +wonderswan) + readonly PLAYLIST_NAME="Bandai - WonderSwan" + ;; +wonderswancolor) + readonly PLAYLIST_NAME="Bandai - WonderSwan Color" + ;; +x68000) + readonly PLAYLIST_NAME="" + ;; +x1) + readonly PLAYLIST_NAME="" + ;; +zmachine) + readonly PLAYLIST_NAME="" + ;; +zx81) + readonly PLAYLIST_NAME="" + ;; +zxspectrum) + readonly PLAYLIST_NAME="" + ;; + +esac + +if test -f "${PLAYLISTS_FOLDER}"/"${PLAYLIST_NAME}".lpl; then + rm "${PLAYLISTS_FOLDER}"/"${PLAYLIST_NAME}".lpl +fi +touch "${PLAYLISTS_FOLDER}"/"${PLAYLIST_NAME}".lpl + +(echo "{"; +echo " \"version\": \"1.4\","; +echo " \"default_core_path\": \"\","; +echo " \"default_core_name\": \"\","; +echo " \"label_display_mode\": 0,"; +echo " \"right_thumbnail_mode\": 0,"; +echo " \"left_thumbnail_mode\": 0,"; +echo " \"sort_mode\": 0,"; +echo " \"items\": [") >>"${PLAYLISTS_FOLDER}"/"${PLAYLIST_NAME}".lpl +for CHDFILE in "${ROM_FOLDER}"/*.chd; do + GAMENAME="$(basename "$CHDFILE" .chd)" + FOLDER="$(basename "$ROM_FOLDER")" + (echo " {"; + echo " \"path\": \"${BASE_PATH}/${FOLDER}/${GAMENAME}.chd\","; + echo " \"label\": \"${GAMENAME}\","; + echo " \"core_path\": \"DETECT\","; + echo " \"core_name\": \"DETECT\","; + echo " \"db_name\": \"${PLAYLIST_NAME}.lpl\""; + echo " },") >>"${PLAYLISTS_FOLDER}"/"${PLAYLIST_NAME}".lpl +done +(echo " ]"; +echo "}") >>"${PLAYLISTS_FOLDER}"/"${PLAYLIST_NAME}".lpl diff --git a/retroarch/create_retroarch_thumbnails.sh b/retroarch/create_retroarch_thumbnails.sh new file mode 100755 index 0000000..9b6ffb5 --- /dev/null +++ b/retroarch/create_retroarch_thumbnails.sh @@ -0,0 +1,298 @@ +#!/bin/bash +function help_message() { + printf "%s\n\n" "$USAGE" + printf "%s" "Where [SYSTEMS] are: " + for WORD in $SYSTEMS; do + printf "%s" "$WORD " + done + printf "\n" +} + +readonly USAGE=" +USAGE: +$(basename "$0") [SYSTEM] [ROM_FOLDER] [THUMBNAILS_FOLDER]" + +readonly SYSTEMS="pcenginecd 3do 3ds amiga amstradcpc apple2 arcade arcadia astrocde atari800 atari2600 atari5200 atari7800 atarijaguar atarilynx atarist c16 c64 c128 coco coleco daphne dragon32 dreamcast fba fds gameandwatch gamegear gb gba gbc gc genesis intellivision mame-advmame mame-libretro mame-mame4all mastersystem megacd megadrive msx n64 nds neogeo nes ngp ngpc oric pc pc88 pc98 pcfx pcengine pokemini ports ps2 psp psx saturn scummvm sega32x segacd sg-1000 snes steam ti99 trs-80 vectrex vic20 videopac virtualboy wii wonderswan wonderswancolor x68000 x1 zmachine zx81 zxspectrum" + +# check if there are all the parameters +if [ "$#" -ne 3 ]; then + help_message + exit 0 +fi + +# check if the system parameter is valid +if ! echo "$SYSTEMS" | grep -w "$1" >/dev/null; then + printf "%s\n" "You must enter a valid system name." + help_message + exit 0 +fi + +if ! test -d "${ROM_FOLDER}"/"${SYSTEM}"; then + echo "${ROM_FOLDER}"/"${SYSTEM}" does not exists + exit 0 +fi + +#readonly SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +readonly SYSTEM="$1" +readonly ROM_FOLDER="$2" +readonly THUMBNAILS_FOLDER="$3" + +case $SYSTEM in + +3do) + readonly PLAYLIST_NAME="" + ;; +3ds) + readonly PLAYLIST_NAME="" + ;; +amiga) + readonly PLAYLIST_NAME="" + ;; +amstradcpc) + readonly PLAYLIST_NAME="" + ;; +apple2) + readonly PLAYLIST_NAME="" + ;; +arcade) + readonly PLAYLIST_NAME="FBNeo - Arcade Games" + ;; +arcadia) + readonly PLAYLIST_NAME="" + ;; +astrocde) + readonly PLAYLIST_NAME="" + ;; +atari800) + readonly PLAYLIST_NAME="" + ;; +atari2600) + readonly PLAYLIST_NAME="Atari - 2600" + ;; +atari5200) + readonly PLAYLIST_NAME="" + ;; +atari7800) + readonly PLAYLIST_NAME="Atari - 7800" + ;; +atarijaguar) + readonly PLAYLIST_NAME="" + ;; +atarilynx) + readonly PLAYLIST_NAME="Atari - Lynx" + ;; +atarist) + readonly PLAYLIST_NAME="" + ;; +c16) + readonly PLAYLIST_NAME="" + ;; +c64) + readonly PLAYLIST_NAME="" + ;; +c128) + readonly PLAYLIST_NAME="" + ;; +coco) + readonly PLAYLIST_NAME="" + ;; +coleco) + readonly PLAYLIST_NAME="Coleco - ColecoVision" + ;; +daphne) + readonly PLAYLIST_NAME="" + ;; +dragon32) + readonly PLAYLIST_NAME="" + ;; +dreamcast) + readonly PLAYLIST_NAME="" + ;; +fba) + readonly PLAYLIST_NAME="" + ;; +fds) + readonly PLAYLIST_NAME="" + ;; +gameandwatch) + readonly PLAYLIST_NAME="" + ;; +gamegear) + readonly PLAYLIST_NAME="Sega - Game Gear" + ;; +gb) + readonly PLAYLIST_NAME="Nintendo - Game Boy" + ;; +gba) + readonly PLAYLIST_NAME="Nintendo - Game Boy Advance" + ;; +gbc) + readonly PLAYLIST_NAME="Nintendo - Game Boy Color" + ;; +gc) + readonly PLAYLIST_NAME="" + ;; +genesis) + readonly PLAYLIST_NAME="" + ;; +intellivision) + readonly PLAYLIST_NAME="" + ;; +mame-advmame) + readonly PLAYLIST_NAME="" + ;; +mame-libretro) + readonly PLAYLIST_NAME="" + ;; +mame-mame4all) + readonly PLAYLIST_NAME="" + ;; +mastersystem) + readonly PLAYLIST_NAME="Sega - Master System - Mark III" + ;; +megacd) + readonly PLAYLIST_NAME="Sega - Mega-CD - Sega CD" + ;; +megadrive) + readonly PLAYLIST_NAME="Sega - Mega Drive - Genesis" + ;; +msx) + readonly PLAYLIST_NAME="Microsoft - MSX" + ;; +msx2) + readonly PLAYLIST_NAME="Microsoft - MSX2" + ;; +n64) + readonly PLAYLIST_NAME="Nintendo - Nintendo 64" + ;; +nds) + readonly PLAYLIST_NAME="Nintendo - Nintendo DS" + ;; +neogeo) + readonly PLAYLIST_NAME="" + ;; +nes) + readonly PLAYLIST_NAME="Nintendo - Nintendo Entertainment System" + ;; +ngp) + readonly PLAYLIST_NAME="SNK - Neo Geo Pocket" + ;; +ngpc) + readonly PLAYLIST_NAME="SNK - Neo Geo Pocket Color" + ;; +oric) + readonly PLAYLIST_NAME="" + ;; +pc) + readonly PLAYLIST_NAME="" + ;; +pc88) + readonly PLAYLIST_NAME="" + ;; +pc98) + readonly PLAYLIST_NAME="" + ;; +pcfx) + readonly PLAYLIST_NAME="" + ;; +pcengine) + readonly PLAYLIST_NAME="NEC - PC Engine - TurboGrafx 16" + ;; +pcenginecd) + readonly PLAYLIST_NAME="NEC - PC Engine CD" + ;; +pokemini) + readonly PLAYLIST_NAME="" + ;; +ports) + readonly PLAYLIST_NAME="" + ;; +ps2) + readonly PLAYLIST_NAME="" + ;; +psp) + readonly PLAYLIST_NAME="" + ;; +psx) + readonly PLAYLIST_NAME="Sony - PlayStation" + ;; +saturn) + readonly PLAYLIST_NAME="" + ;; +scummvm) + readonly PLAYLIST_NAME="" + ;; +sega32x) + readonly PLAYLIST_NAME="" + ;; +segacd) + readonly PLAYLIST_NAME="Sega - Mega-CD - Sega CD" + ;; +sg-1000) + readonly PLAYLIST_NAME="Sega - SG-1000" + ;; +snes) + readonly PLAYLIST_NAME="Nintendo - Super Nintendo Entertainment System" + ;; +steam) + readonly PLAYLIST_NAME="" + ;; +ti99) + readonly PLAYLIST_NAME="" + ;; +trs-80) + readonly PLAYLIST_NAME="" + ;; +vectrex) + readonly PLAYLIST_NAME="" + ;; +vic20) + readonly PLAYLIST_NAME="" + ;; +videopac) + readonly PLAYLIST_NAME="" + ;; +virtualboy) + readonly PLAYLIST_NAME="" + ;; +wii) + readonly PLAYLIST_NAME="" + ;; +wonderswan) + readonly PLAYLIST_NAME="Bandai - WonderSwan" + ;; +wonderswancolor) + readonly PLAYLIST_NAME="Bandai - WonderSwan Color" + ;; +x68000) + readonly PLAYLIST_NAME="" + ;; +x1) + readonly PLAYLIST_NAME="" + ;; +zmachine) + readonly PLAYLIST_NAME="" + ;; +zx81) + readonly PLAYLIST_NAME="" + ;; +zxspectrum) + readonly PLAYLIST_NAME="" + ;; + +esac + +if test -d "${THUMBNAILS_FOLDER}"/"${PLAYLIST_NAME}"; then + rm -rdf "${THUMBNAILS_FOLDER:?}"/"${PLAYLIST_NAME:?}" +fi + +mkdir -p "${THUMBNAILS_FOLDER}"/"${PLAYLIST_NAME}" +mkdir -p "${THUMBNAILS_FOLDER}"/"${PLAYLIST_NAME}"/Named_Boxarts +mkdir -p "${THUMBNAILS_FOLDER}"/"${PLAYLIST_NAME}"/Named_Snaps +mkdir -p "${THUMBNAILS_FOLDER}"/"${PLAYLIST_NAME}"/Named_Titles + +cp -v "${ROM_FOLDER}"/"${SYSTEM}"/media/covers/* "${THUMBNAILS_FOLDER}"/"${PLAYLIST_NAME}"/Named_Boxarts +cp -v "${ROM_FOLDER}"/"${SYSTEM}"/media/screenshots/* "${THUMBNAILS_FOLDER}"/"${PLAYLIST_NAME}"/Named_Snaps + +rename s-[\&\*\:\`\<\>\?\\\|]-_- "${THUMBNAILS_FOLDER}"/"${PLAYLIST_NAME}"/Named_Boxarts/* +rename s-[\&\*\:\`\<\>\?\\\|]-_- "${THUMBNAILS_FOLDER}"/"${PLAYLIST_NAME}"/Named_Snaps/* diff --git a/retroarch/create_retroarch_thumbnails_all.sh b/retroarch/create_retroarch_thumbnails_all.sh new file mode 100755 index 0000000..4810f08 --- /dev/null +++ b/retroarch/create_retroarch_thumbnails_all.sh @@ -0,0 +1,33 @@ +#!/bin/bash +function help_message() { + echo "$USAGE" + echo + echo "Where [SYSTEMS] are:" + for WORD in $SYSTEMS; do + echo -e "\t$WORD" + done +} + +readonly USAGE=" +USAGE: +$(basename "$0") [ROM_FOLDER] [THUMBNAILS_FOLDER]" + +# check if there are all the parameters +if [ "$#" -ne 2 ]; then + help_message + exit 0 +fi + +if ! test -d "${ROM_FOLDER}"/"${SYSTEM}"; then + echo "${ROM_FOLDER}"/"${SYSTEM}" does not exists + exit 0 +fi + +readonly ROM_FOLDER="$1" +readonly THUMBNAILS_FOLDER="$2" +readonly SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +readonly SYSTEMS="pcenginecd 3do 3ds amiga amstradcpc apple2 arcade arcadia astrocde atari800 atari2600 atari5200 atari7800 atarijaguar atarilynx atarist c16 c64 c128 coco coleco daphne dragon32 dreamcast fba fds gameandwatch gamegear gb gba gbc gc genesis intellivision mame-advmame mame-libretro mame-mame4all mastersystem megacd megadrive msx n64 nds neogeo nes ngp ngpc oric pc pc88 pc98 pcfx pcengine pokemini ports ps2 psp psx saturn scummvm sega32x segacd sg-1000 snes steam ti99 trs-80 vectrex vic20 videopac virtualboy wii wonderswan wonderswancolor x68000 x1 zmachine zx81 zxspectrum" + +for SYSTEM in $SYSTEMS; do + "${SCRIPT_DIR}"/create_retroarch_thumbnails.sh "${SYSTEM}" "${ROM_FOLDER}" "${THUMBNAILS_FOLDER}" +done diff --git a/retroarch/rename_retroarch_arcade_thumbnails.sh b/retroarch/rename_retroarch_arcade_thumbnails.sh new file mode 100755 index 0000000..172ff75 --- /dev/null +++ b/retroarch/rename_retroarch_arcade_thumbnails.sh @@ -0,0 +1,53 @@ +#!/bin/bash +function help_message() { + echo "$USAGE" +} + +USAGE=" +USAGE: +$(basename "$0") [arcade_playlist] [thumbnail_folder]" +readonly USAGE + +# check if there are all the parameters +if [ "$#" -ne 2 ]; then + help_message + exit 0 +fi + +readonly ARCADE_PLAYLIST="$1" +readonly THUMBNAIL_FOLDER="$2" +readonly TEMP_FILE="${THUMBNAIL_FOLDER}"/temp + +if ! test -d "${THUMBNAIL_FOLDER}"; then + echo "${THUMBNAIL_FOLDER}" does not exists + exit 0 +fi + +if ! test -f "${ARCADE_PLAYLIST}"; then + echo "${ARCADE_PLAYLIST}" does not exists + exit 0 +fi + +if test -d "${THUMBNAIL_FOLDER}".bak; then + echo deleted "${THUMBNAIL_FOLDER}".bak + rm -rdf "${THUMBNAIL_FOLDER:?}" +fi + +if ! test -d "${THUMBNAIL_FOLDER}".bak; then + #echo created "${THUMBNAIL_FOLDER}".bak + clear +fi + +CURRENT_DIR=$(pwd) +readonly CURRENT_DIR +cd "${THUMBNAIL_FOLDER}" || return +rm -v "${TEMP_FILE}" +#grep -e \"label\" -e \"path\" "${ARCADE_PLAYLIST}" | sed s-"$(printf '\r')"-OO-g +# | sed -E 's- \"path\": \"-cp \"-g' | sed -E 's-^ \"label\": -X-g' | sed -E 's-,$-X-g' > "${TEMP_FILE}" +while IFS= read -r line +do + echo "$line" +done < "$input" + +cd "${CURRENT_DIR}" || return +date \ No newline at end of file