Update NSLGameScanner.py

This commit is contained in:
Roy 2024-02-18 06:23:09 -08:00 committed by GitHub
parent f62bc75eda
commit b604b45b11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1018,32 +1018,32 @@ 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()]
for game in games: # Create the path to the output file
# Skip if 'appname' or 'exe' is None output_file_path = f"{logged_in_home}/.config/systemd/user/NSLGameScanner_output.log"
if game.get('appname') is None or game.get('exe') is None:
continue
# Create a dictionary to hold the shortcut information # Open the output file in append mode
shortcut_info = { with open(output_file_path, 'a') as output_file:
'appid': str(game.get('appid')), for game in games:
'appname': game.get('appname'), # Skip if 'appname' or 'exe' is None
'exe': game.get('exe'), if game.get('appname') is None or game.get('exe') is None:
'StartDir': game.get('StartDir'), continue
'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
}
# Print the shortcut information in JSON format # Create a dictionary to hold the shortcut information
message = json.dumps(shortcut_info) shortcut_info = {
print(message, flush=True) # Print to stdout '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
}
# Print the shortcut information in JSON format
message = json.dumps(shortcut_info)
print(message, flush=True) # Print to stdout
# Print the shortcut information to the output file
print(message, file=output_file, flush=True)
print("All finished!") print("All finished!")
# Create the path to the output file
output_file_path = f"{logged_in_home}/.config/systemd/user/NSLGameScanner_output.log"
# Open the output file in append mode
with open(output_file_path, 'a') as output_file:
# Print the shortcut information to the output file
print(message, file=output_file, flush=True)