fixes and improvements

This commit is contained in:
Dragoon Dorise 2024-05-20 23:04:04 +02:00
parent 863d78af2e
commit ef9a128331
3 changed files with 38 additions and 53 deletions

View File

@ -9,67 +9,51 @@ generateGameLists() {
generateGameListsJson() {
cat $HOME/emudeck/roms_games.json
generateGameLists_artwork "-r" &> /dev/null &
#generateGameLists_artwork &> /dev/null &
}
generateGameLists_artwork() {
direction=$1
json=$(cat $HOME/emudeck/roms_games.json)
mapfile -t games_array < <(echo "$json" | jq -r '.[] | .games[]? | .name' | sed -e 's/ (.*)//g' -e 's/ /_/g')
json=$(cat "$HOME/emudeck/roms_games.json")
platforms=$(echo "$json" | jq -r '.[].id')
mapfile -t sorted_games_array < <(printf "%s\n" "${games_array[@]}" | sort $direction)
accountfolder=$(ls -d $HOME/.steam/steam/userdata/* | head -n 1)
dest_folder="$accountfolder/config/grid/"
mkdir -p "$dest_folder"
accountfolder=$(ls -d $HOME/.steam/steam/userdata/* | head -n 1)
dest_folder="$accountfolder/config/grid/"
mkdir -p "$dest_folder"
for platform in $platforms; do
echo "Processing platform: $platform"
games=$(echo "$json" | jq -r --arg platform "$platform" '.[] | select(.id == $platform) | .games[]?.name')
# Imprime los nombres limpios almacenados en el array
for game in "${games_array[@]}"; do
declare -a download_array
declare -a download_dest_paths
declare -a download_array
declare -a download_dest_paths
declare -a valid_system_dirs
for game in $games; do
file_to_check="$dest_folder${game// /_}*"
if ! ls $file_to_check 1> /dev/null 2>&1; then
echo "$game"
file_to_check="$dest_folder$game*"
response=$(curl -s -G "https://bot.emudeck.com/steamdbimg.php?name=$game")
game_name=$(echo "$response" | jq -r '.name')
game_img_url=$(echo "$response" | jq -r '.img')
filename=$(basename "$game_img_url")
dest_path="$dest_folder$game.jpg"
if [ ! -f "$dest_path" ]; then
download_array+=("$game_img_url")
download_dest_paths+=("$dest_path")
fi
fi
done
# Download images for the current platform
for i in "${!download_array[@]}"; do
{
curl -s -o "${download_dest_paths[$i]}" "${download_array[$i]}"
} &
done
wait
if ! ls $file_to_check 1> /dev/null 2>&1; then
echo $game
response=$(curl -s -G "https://bot.emudeck.com/steamdbimg.php?name=$game")
game_name=$(echo "$response" | jq -r '.name')
game_img_url=$(echo "$response" | jq -r '.img')
game_img=$(echo "$game_img_url" | sed 's|.*/||')
filename=$(basename "$game_img_url")
dest_path="$dest_folder$game.jpg"
if [ ! -f "$dest_path" ]; then
#echo "Adding $game_img_url to download array"
echo $game_img_url
download_array+=("$game_img_url")
download_dest_paths+=("$dest_path")
fi
fi
# Ensure the download array is not empty
#echo "Download array length: ${#download_array[@]}"
# if [ ${#download_array[@]} -eq 0 ]; then
# #echo "No images to download."
# return
# fi
# Download images in parallel
#echo "Starting downloads..."
for i in "${!download_array[@]}"; do
{
#echo "Downloading ${download_array[$i]} to ${download_dest_paths[$i]}"
curl -o "${download_dest_paths[$i]}" "${download_array[$i]}"
} &
done
wait
#echo "Downloads completed."
done
echo "Completed downloads for platform: $platform"
done
}

View File

@ -1,4 +1,4 @@
collection: Saturn
collection: Sega Saturn
shortname: saturn
extensions: bin, BIN, ccd, CCD, chd, CHD, cue, CUE, iso, ISO, mds, MDS, toc, TOC, m3u, M3U, 7z, 7Z, zip, ZIP
launch: /run/media/mmcblk0p1/Emulation/tools/launchers/retroarch.sh -L CORESPATH/mednafen_saturn_libretro.so {file.path}

View File

@ -14,6 +14,7 @@ def generate_game_lists(roms_path):
if extension in extensions:
name_cleaned = re.sub(r'\(.*?\)', '', name)
name_cleaned = re.sub(r'\[.*?\]', '', name_cleaned)
name_cleaned = name_cleaned.strip()
name_cleaned = name_cleaned.replace(' ', '_')
name_cleaned = name_cleaned.replace('-', '_')
@ -22,7 +23,7 @@ def generate_game_lists(roms_path):
clean_name = name_cleaned
game_img = f"/customimages/{clean_name}.jpg"
game_info = {
"name": name,
"name": clean_name,
"filename": os.path.join(root, file),
"img": game_img
}