mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-12-21 07:11:52 +01:00
Correctly Parse Ubisoft Connect games locally
~using the folders and the registry entries
This commit is contained in:
parent
b7c6f3dca4
commit
f6e979d5e5
@ -417,61 +417,46 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
#Ubisoft Connect Scanner
|
#Ubisoft Connect Scanner
|
||||||
def getUplayIDsFromGitHub():
|
def getUplayGameInfo(folderPath, filePath):
|
||||||
url = 'https://raw.githubusercontent.com/Haoose/UPLAY_GAME_ID/master/README.md'
|
# Get the game IDs from the folder
|
||||||
try:
|
listOfFiles = os.listdir(folderPath)
|
||||||
response = urlopen(url)
|
game_ids = [re.findall(r'\d+', str(entry))[0] for entry in listOfFiles if re.findall(r'\d+', str(entry))]
|
||||||
data = response.read().decode()
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error occurred: {e}")
|
|
||||||
return {}
|
|
||||||
|
|
||||||
|
# Parse the registry file
|
||||||
game_dict = {}
|
game_dict = {}
|
||||||
for line in data.split('\n'):
|
with open(filePath, 'r') as file:
|
||||||
match = re.match(r'\s*(\d+)\s*-\s*(.*)', line)
|
game_id = None
|
||||||
if match:
|
game_name = None
|
||||||
id, game = match.groups()
|
uplay_install_found = False
|
||||||
game_dict[game.strip()] = id.strip()
|
for line in file:
|
||||||
|
if "Uplay Install" in line:
|
||||||
|
game_id = re.findall(r'Uplay Install (\d+)', line)
|
||||||
|
if game_id:
|
||||||
|
game_id = game_id[0]
|
||||||
|
game_name = None # Reset game_name
|
||||||
|
uplay_install_found = True
|
||||||
|
if "DisplayName" in line and uplay_install_found:
|
||||||
|
game_name = re.findall(r'\"(.+?)\"', line.split("=")[1])
|
||||||
|
if game_name:
|
||||||
|
game_name = game_name[0]
|
||||||
|
uplay_install_found = False
|
||||||
|
if game_id and game_name and game_id in game_ids: # Add the game's info to the dictionary if its ID was found in the folder
|
||||||
|
game_dict[game_name] = game_id
|
||||||
|
game_id = None # Reset game_id
|
||||||
|
game_name = None # Reset game_name
|
||||||
|
|
||||||
return game_dict
|
return game_dict
|
||||||
|
|
||||||
def getUplayIDsFromDataFolder(filePath):
|
|
||||||
if not os.path.exists(filePath):
|
|
||||||
print(f"Path {filePath} does not exist.")
|
|
||||||
return {}
|
|
||||||
|
|
||||||
listOfFiles = os.listdir(filePath)
|
|
||||||
def findIDs(entry):
|
|
||||||
result = re.findall(r'\d+', str(entry))
|
|
||||||
try: return result[0]
|
|
||||||
except: pass
|
|
||||||
|
|
||||||
data_dict = {}
|
|
||||||
for entry in listOfFiles:
|
|
||||||
uPlayID = findIDs(entry)
|
|
||||||
if uPlayID != None:
|
|
||||||
gameName = entry.replace(uPlayID, '').strip()
|
|
||||||
data_dict[gameName] = uPlayID
|
|
||||||
|
|
||||||
return data_dict
|
|
||||||
|
|
||||||
def getInstalledGames(filePath):
|
|
||||||
if not os.path.exists(filePath):
|
|
||||||
print(f"Path {filePath} does not exist.")
|
|
||||||
return []
|
|
||||||
|
|
||||||
return os.listdir(filePath)
|
|
||||||
|
|
||||||
# Define your paths
|
# Define your paths
|
||||||
data_folder_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/pfx/drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/data/"
|
data_folder_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/pfx/drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/data/"
|
||||||
games_folder_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/pfx/drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/games/"
|
games_folder_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/pfx/drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/games/"
|
||||||
|
registry_file_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/pfx/system.reg"
|
||||||
|
|
||||||
# Check if the paths exist
|
# Check if the paths exist
|
||||||
if not os.path.exists(data_folder_path) or not os.path.exists(games_folder_path):
|
if not os.path.exists(data_folder_path) or not os.path.exists(games_folder_path) or not os.path.exists(registry_file_path):
|
||||||
print("One or more paths do not exist.")
|
print("One or more paths do not exist.")
|
||||||
else:
|
else:
|
||||||
game_dict = getUplayIDsFromGitHub()
|
game_dict = getUplayGameInfo(data_folder_path, registry_file_path)
|
||||||
data_dict = getUplayIDsFromDataFolder(data_folder_path)
|
|
||||||
installed_games = getInstalledGames(games_folder_path)
|
installed_games = getInstalledGames(games_folder_path)
|
||||||
|
|
||||||
# Load the shortcuts and config_data objects
|
# Load the shortcuts and config_data objects
|
||||||
@ -486,7 +471,7 @@ else:
|
|||||||
new_shortcuts_added = False
|
new_shortcuts_added = False
|
||||||
|
|
||||||
for game in installed_games:
|
for game in installed_games:
|
||||||
game_id = game_dict.get(game) or data_dict.get(game)
|
game_id = game_dict.get(game)
|
||||||
if game_id:
|
if game_id:
|
||||||
launch_options = f"STEAM_COMPAT_DATA_PATH=\"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/\" %command% \"uplay://launch/{game_id}/0\""
|
launch_options = f"STEAM_COMPAT_DATA_PATH=\"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/\" %command% \"uplay://launch/{game_id}/0\""
|
||||||
exe_path = f"\"{logged_in_home}/.local/share/Steam/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/pfx/drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/upc.exe\""
|
exe_path = f"\"{logged_in_home}/.local/share/Steam/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/pfx/drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/upc.exe\""
|
||||||
|
Loading…
Reference in New Issue
Block a user