This commit is contained in:
Roy 2024-02-18 00:17:20 -08:00 committed by GitHub
parent cdff413f4c
commit e5153c06e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1018,31 +1018,26 @@ if new_shortcuts_added or shortcuts_updated:
# Assuming 'games' is a list of game dictionaries # Assuming 'games' is a list of game dictionaries
games = [shortcut for shortcut in shortcuts['shortcuts'].values()] games = [shortcut for shortcut in shortcuts['shortcuts'].values()]
# Open the output file in write mode ('w') for game in games:
with open('output.json', 'w') as outfile: # Skip if 'appname' or 'exe' is None
for game in games: if game.get('appname') is None or game.get('exe') is None:
# Skip if 'appname' or 'exe' is None continue
if game.get('appname') is None or game.get('exe') is None:
continue
# Create a dictionary to hold the shortcut information # Create a dictionary to hold the shortcut information
shortcut_info = { shortcut_info = {
'appid': str(game.get('appid')), 'appid': str(game.get('appid')),
'appname': game.get('appname'), 'appname': game.get('appname'),
'exe': game.get('exe'), 'exe': game.get('exe'),
'StartDir': game.get('StartDir'), 'StartDir': game.get('StartDir'),
'icon': f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/grid/{get_file_name('icons', game.get('appid'))}", 'icon': f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/grid/{get_file_name('icons', game.get('appid'))}",
'LaunchOptions': game.get('LaunchOptions'), 'LaunchOptions': game.get('LaunchOptions'),
'GameID': game.get('GameID', "default_game_id") # Use a default value if game_id is not defined 'GameID': game.get('GameID', "default_game_id") # Use a default value if game_id is not defined
} }
# Convert the shortcut information to JSON format # Print the shortcut information in JSON format
message = json.dumps(shortcut_info) message = json.dumps(shortcut_info)
print(message, flush=True) # Print to stdout
# Write the JSON output to the file
outfile.write(message + '\n') # Add a newline character after each game
print("All finished!")
print("All finished!")