Skip to content

Commit

Permalink
Update NSLGameScanner.py
Browse files Browse the repository at this point in the history
  • Loading branch information
moraroy committed Jun 22, 2024
1 parent b6d7b71 commit c6a9cff
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions NSLGameScanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,36 @@ def get_unsigned_shortcut_id(signed_shortcut_id):
hero64 = ""


# 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())

def create_empty_shortcuts():
return {'shortcuts': {}}

def write_shortcuts_to_file(shortcuts_file, shortcuts):
with open(shortcuts_file, 'wb') as file:
file.write(vdf.binary_dumps(shortcuts))
os.chmod(shortcuts_file, 0o755)

# Define the path to the shortcuts file
shortcuts_file = f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf"

# Check if the file exists
if os.path.exists(shortcuts_file):
# If the file is not executable, write the shortcuts dictionary and make it executable
if not os.access(shortcuts_file, os.X_OK):
print("The file is not executable. Writing an empty shortcuts dictionary and making it executable.")
shortcuts = create_empty_shortcuts()
write_shortcuts_to_file(shortcuts_file, shortcuts)
else:
# Load the existing shortcuts
with open(shortcuts_file, 'rb') as file:
try:
shortcuts = vdf.binary_loads(file.read())
except vdf.VDFError as e:
print(f"Error reading file: {e}")
shortcuts = create_empty_shortcuts()
else:
print("The shortcuts.vdf file does not exist.")
sys.exit(1)

# Open the config.vdf file
with open(f"{logged_in_home}/.steam/root/config/config.vdf", 'r') as file:
Expand Down

0 comments on commit c6a9cff

Please sign in to comment.