From e5153c06e076041400d13d4fca1d9e2cfbafc876 Mon Sep 17 00:00:00 2001 From: Roy <88516395+moraroy@users.noreply.github.com> Date: Sun, 18 Feb 2024 00:17:20 -0800 Subject: [PATCH] Reverted --- NSLGameScanner.py | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/NSLGameScanner.py b/NSLGameScanner.py index 0c41505..894533f 100644 --- a/NSLGameScanner.py +++ b/NSLGameScanner.py @@ -1018,31 +1018,26 @@ if new_shortcuts_added or shortcuts_updated: # Assuming 'games' is a list of game dictionaries games = [shortcut for shortcut in shortcuts['shortcuts'].values()] - # Open the output file in write mode ('w') - with open('output.json', 'w') as outfile: - for game in games: - # Skip if 'appname' or 'exe' is None - if game.get('appname') is None or game.get('exe') is None: - continue + for game in games: + # Skip if 'appname' or 'exe' is None + if game.get('appname') is None or game.get('exe') is None: + continue - # Create a dictionary to hold the shortcut information - shortcut_info = { - 'appid': str(game.get('appid')), - 'appname': game.get('appname'), - 'exe': game.get('exe'), - 'StartDir': game.get('StartDir'), - 'icon': f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/grid/{get_file_name('icons', game.get('appid'))}", - 'LaunchOptions': game.get('LaunchOptions'), - 'GameID': game.get('GameID', "default_game_id") # Use a default value if game_id is not defined - } + # Create a dictionary to hold the shortcut information + shortcut_info = { + 'appid': str(game.get('appid')), + 'appname': game.get('appname'), + 'exe': game.get('exe'), + 'StartDir': game.get('StartDir'), + 'icon': f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/grid/{get_file_name('icons', game.get('appid'))}", + 'LaunchOptions': game.get('LaunchOptions'), + 'GameID': game.get('GameID', "default_game_id") # Use a default value if game_id is not defined + } - # Convert the shortcut information to JSON format - message = json.dumps(shortcut_info) - - # Write the JSON output to the file - outfile.write(message + '\n') # Add a newline character after each game - - print("All finished!") + # Print the shortcut information in JSON format + message = json.dumps(shortcut_info) + print(message, flush=True) # Print to stdout +print("All finished!")