mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-12-21 15:21:52 +01:00
Update NSLGameScanner.py
This commit is contained in:
parent
fdfedc6dd9
commit
e5b74f46c4
@ -196,33 +196,14 @@ hero64 = ""
|
||||
# Define the path to the shortcuts file
|
||||
shortcuts_file = f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf"
|
||||
|
||||
# Check if the shortcuts file exists
|
||||
if os.path.exists(shortcuts_file):
|
||||
# If the file exists, try to load it
|
||||
try:
|
||||
with open(shortcuts_file, 'rb') as file:
|
||||
shortcuts = vdf.binary_loads(file.read())
|
||||
except Exception as e:
|
||||
print(f"Error reading shortcuts file: {e}")
|
||||
print("Please check the file and try again.")
|
||||
sys.exit() # Exit the script if an error occurs
|
||||
|
||||
# If the file is empty or does not contain the 'shortcuts' key, initialize an empty 'shortcuts' dictionary
|
||||
if not shortcuts or 'shortcuts' not in shortcuts:
|
||||
shortcuts = {'shortcuts': {}}
|
||||
|
||||
# Check data integrity before writing to file
|
||||
if shortcuts and isinstance(shortcuts, dict) and 'shortcuts' in shortcuts:
|
||||
with open(shortcuts_file, 'wb') as file:
|
||||
vdf.binary_dumps(shortcuts, file)
|
||||
else:
|
||||
print("The data to be written to the shortcuts file is not valid.")
|
||||
|
||||
|
||||
# Load the existing shortcuts
|
||||
with open(f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf", 'rb') as file:
|
||||
shortcuts = vdf.binary_loads(file.read())
|
||||
# Open the config.vdf file
|
||||
with open(f"{logged_in_home}/.steam/root/config/config.vdf", 'r') as file:
|
||||
config_data = vdf.load(file)
|
||||
|
||||
|
||||
def get_sgdb_art(game_id, app_id):
|
||||
global grid64
|
||||
global gridp64
|
||||
@ -1108,7 +1089,6 @@ for game in games:
|
||||
|
||||
|
||||
|
||||
|
||||
# Only write back to the shortcuts.vdf and config.vdf files if new shortcuts were added or compattools changed
|
||||
if new_shortcuts_added or shortcuts_updated:
|
||||
print(f"Saving new config and shortcuts files")
|
||||
|
Loading…
Reference in New Issue
Block a user