Update NSLGameScanner.py

This commit is contained in:
Roy 2024-05-07 23:20:09 -07:00 committed by GitHub
parent b8835534d9
commit 471d63b27c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -739,49 +739,43 @@ def getGogGameInfo(filePath):
exe_path = None exe_path = None
depends_on = None depends_on = None
launch_command = None launch_command = None
start_menu_link = None
for line in file: for line in file:
split_line = line.split("=") if "[Software\\Wow6432Node\\GOG.com\\Games\\" in line:
if len(split_line) > 1: split_line = line.split("=")
if "gameID" in line: if len(split_line) > 1:
game_id = re.findall(r'\"(.+?)\"', split_line[1]) if "gameID" in line:
if game_id: game_id = re.findall(r'\"(.+?)\"', split_line[1])
game_id = game_id[0] if game_id:
if "gameName" in line: game_id = game_id[0]
game_name = re.findall(r'\"(.+?)\"', split_line[1]) if "gameName" in line:
if game_name: game_name = re.findall(r'\"(.+?)\"', split_line[1])
game_name = bytes(game_name[0], 'utf-8').decode('unicode_escape') if game_name:
game_name = game_name.replace('!22', '') game_name = bytes(game_name[0], 'utf-8').decode('unicode_escape')
if "exe" in line and "GOG Galaxy" in line and not "unins000.exe" in line: game_name = game_name.replace('!22', '')
exe_path = re.findall(r'\"(.+?)\"', split_line[1]) if "exe" in line and "GOG Galaxy" in line and not "unins000.exe" in line:
if exe_path: exe_path = re.findall(r'\"(.+?)\"', split_line[1])
exe_path = exe_path[0].replace('\\\\', '\\') if exe_path:
if "dependsOn" in line: exe_path = exe_path[0].replace('\\\\', '\\')
depends_on = re.findall(r'\"(.+?)\"', split_line[1]) if "dependsOn" in line:
if depends_on: depends_on = re.findall(r'\"(.+?)\"', split_line[1])
depends_on = depends_on[0] if depends_on:
if "launchCommand" in line: depends_on = depends_on[0]
launch_command = re.findall(r'\"(.+?)\"', split_line[1]) if "launchCommand" in line:
if launch_command: launch_command = re.findall(r'\"(.+?)\"', split_line[1])
launch_command = launch_command[0] if launch_command:
if "startMenuLink" in line: launch_command = launch_command[0]
start_menu_link = re.findall(r'\"(.+?)\"', split_line[1]) if game_id and game_name and launch_command:
if start_menu_link: game_dict[game_name] = {'id': game_id, 'exe': exe_path}
start_menu_link = start_menu_link[0] game_id = None
if game_id and game_name and launch_command and start_menu_link and "[GOG.com]" in start_menu_link: game_name = None
game_dict[game_name] = {'id': game_id, 'exe': exe_path} exe_path = None
game_id = None depends_on = None
game_name = None launch_command = None
exe_path = None
depends_on = None
launch_command = None
start_menu_link = None
return game_dict return game_dict
# Define your paths # Define your paths
gog_games_directory = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{gog_galaxy_launcher}/pfx/drive_c/Program Files (x86)/GOG Galaxy/Games" gog_games_directory = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{gog_galaxy_launcher}/pfx/drive_c/Program Files (x86)/GOG Galaxy/Games"
registry_file_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{gog_galaxy_launcher}/pfx/system.reg" registry_file_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{gog_galaxy_launcher}/pfx/system.reg"