im working on a .py for arch linux but im getting some duplication in the shortcuts where is the error or oversight? #Ubisoft Connect Scanner
def getUplayGameInfo(folderPath, filePath):
    # Get the game IDs from the folder
    listOfFiles = os.listdir(folderPath)
    game_ids = [re.findall(r'\d+', str(entry))[0] for entry in listOfFiles if re.findall(r'\d+', str(entry))]

    # Parse the registry file
    game_dict = {}
    with open(filePath, 'r') as file:
        game_id = None
        game_name = None
        uplay_install_found = False
        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

# 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/"
registry_file_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/pfx/system.reg"

# Check if the paths exist
if not os.path.exists(data_folder_path) or not os.path.exists(registry_file_path):
    print("One or more paths do not exist.")
else:
    game_dict = getUplayGameInfo(data_folder_path, registry_file_path)

    # Load the shortcuts and config_data objects
    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)

    # Keep track of whether any new shortcuts were added
    new_shortcuts_added = False

    for game, game_id in game_dict.items():
        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\""
            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\""
            start_dir = f"\"{logged_in_home}/.local/share/Steam/Steam/steamapps/compatdata/{ubisoft_connect_launcher}/pfx/drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher/\""
            shortcut_id = get_steam_shortcut_id(exe_path, game)
            game_id = get_game_id(game)
            if game_id is not None:
                for art_type in ["icons", "logos", "heroes", "grids"]:
                    download_artwork(game_id, api_key, art_type, shortcut_id)
                download_artwork(game_id, api_key, "grids", shortcut_id, "600x900")
                download_artwork(game_id, api_key, "grids", shortcut_id, "920x430")
            # Check if the game already exists in the shortcuts
            if not any(s.get('AppName') == game and s.get('Exe') == exe_path and s.get('StartDir') == start_dir and s.get('LaunchOptions') == launch_options for s in shortcuts['shortcuts'].values()):
                new_shortcuts_added = True
                shortcuts['shortcuts'][str(len(shortcuts['shortcuts']))] = {
                    'appid': str(shortcut_id),
                    'AppName': game,
                    'Exe': exe_path,
                    'StartDir': start_dir,
                    'LaunchOptions': launch_options,
                    'icon': f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/grid/{get_file_name('icons', shortcut_id)}"
                }
            if 'CompatToolMapping' not in config_data['InstallConfigStore']['Software']['Valve']['Steam']:
                config_data['InstallConfigStore']['Software']['Valve']['Steam']['CompatToolMapping'] = {}
            if str(shortcut_id) in config_data['InstallConfigStore']['Software']['Valve']['Steam']['CompatToolMapping']:
                config_data['InstallConfigStore']['Software']['Valve']['Steam']['CompatToolMapping'][str(shortcut_id)]['name'] = f'{compat_tool_name}'
                config_data['InstallConfigStore']['Software']['Valve']['Steam']['CompatToolMapping'][str(shortcut_id)]['config'] = ''
                config_data['InstallConfigStore']['Software']['Valve']['Steam']['CompatToolMapping'][str(shortcut_id)]['priority'] = '250'
            else:
                config_data['InstallConfigStore']['Software']['Valve']['Steam']['CompatToolMapping'][str(shortcut_id)] = {'name': '', 'config': '', 'priority': '250'}

    # Only write back to the shortcuts.vdf file if new shortcuts were added
    if new_shortcuts_added:
        with open(f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf", 'wb') as file:
            file.write(vdf.binary_dumps(shortcuts))


#End of Ubisoft Game Scanner

with open(f"{logged_in_home}/.steam/root/config/config.vdf", 'w') as file:
    vdf.dump(config_data, file)

# Print the created shortcuts
    print("Created Shortcuts:")
    for name in created_shortcuts:
        print(name)


print("All finished!")