From c6ae45aecde1e4765d34201372e556268a26efce Mon Sep 17 00:00:00 2001 From: skymike03 Date: Fri, 12 Sep 2025 17:13:05 +0200 Subject: [PATCH] - corrected: ports/RGSX/config.py - add automatic create of api keys .txt files in saves folder --- ports/RGSX/__main__.py | 9 ++++++++- ports/RGSX/network.py | 11 ++++++++++- ports/RGSX/rgsx_cli.py | 7 +++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ports/RGSX/__main__.py b/ports/RGSX/__main__.py index 0680d6a..827b3eb 100644 --- a/ports/RGSX/__main__.py +++ b/ports/RGSX/__main__.py @@ -34,7 +34,7 @@ from controls_mapper import map_controls, draw_controls_mapping, get_actions from controls import load_controls_config from utils import ( load_sources, check_extension_before_download, extract_zip_data, - play_random_music, load_music_config + play_random_music, load_music_config, load_api_keys ) from history import load_history, save_history from config import OTA_data_ZIP @@ -58,6 +58,13 @@ except Exception as e: logger = logging.getLogger(__name__) +# Ensure API key files (1Fichier, AllDebrid, RealDebrid) exist at startup so user can fill them before any download +try: # pragma: no cover + load_api_keys(False) + logger.debug("API key files ensured at startup") +except Exception as _e: + logger.warning(f"Cannot prepare API key files early: {_e}") + # Mise à jour de la gamelist Windows avant toute initialisation graphique (évite les conflits avec ES) def _run_windows_gamelist_update(): try: diff --git a/ports/RGSX/network.py b/ports/RGSX/network.py index 9bb40f1..8ef8f26 100644 --- a/ports/RGSX/network.py +++ b/ports/RGSX/network.py @@ -793,7 +793,16 @@ async def download_from_1fichier(url, platform, game_name, is_zip_non_supported= if "error" in file_info and file_info["error"] == "Resource not found": logger.error(f"Le fichier {game_name} n'existe pas sur 1fichier") result[0] = False - result[1] = f"1F: {_("network_file_not_found").format(game_name)}" if _ else f"1F: File not found {game_name}" + try: + if _: + # Build translated message safely without nesting quotes in f-string + not_found_tpl = _("network_file_not_found") + msg_nf = not_found_tpl.format(game_name) if "{" in not_found_tpl else f"{not_found_tpl} {game_name}" + result[1] = f"1F: {msg_nf}" + else: + result[1] = f"1F: File not found {game_name}" + except Exception: + result[1] = f"1F: File not found {game_name}" return filename = file_info.get("filename", "").strip() if not filename: diff --git a/ports/RGSX/rgsx_cli.py b/ports/RGSX/rgsx_cli.py index 44101b8..85c7946 100644 --- a/ports/RGSX/rgsx_cli.py +++ b/ports/RGSX/rgsx_cli.py @@ -15,6 +15,7 @@ import re # IMPORTANT: Avoid importing display/pygame modules for headless mode import config # paths, settings, SAVE_FOLDER, etc. +from utils import load_api_keys as _prime_api_keys # ensure API key files are created import network as network_mod # for progress_queues access from utils import load_sources, load_games, is_extension_supported, load_extensions_json, sanitize_filename, extract_zip_data from history import load_history, save_history, add_to_history @@ -23,6 +24,12 @@ from rgsx_settings import get_sources_zip_url logger = logging.getLogger("rgsx.cli") +# Ensure API key files exist early so users can edit them without triggering a download first. +try: # pragma: no cover + _prime_api_keys(False) +except Exception: + pass + # Unified size display helper: preserve pre-formatted locale strings (MiB, GiB, Go, Mo, Ko, MB, KB, bytes). # If numeric (int/float or pure digit string), convert to binary units with suffix B, KiB, MiB, GiB.