def _parse_game(self, game_yaml, install_id, launch_id):
        path = ''
        space_id = ''
        third_party_id = ''
        special_registry_path = ''
        status = GameStatus.NotInstalled
        game_type = GameType.New
        game_name = ''
        exe = ''
        launch_id = str(launch_id)
        install_id = str(install_id)

        if 'space_id' in game_yaml['root']:
            space_id = game_yaml['root']['space_id']
        else:
            game_type = GameType.Legacy

        if 'third_party_platform' in game_yaml['root']:
            if game_yaml['root']['third_party_platform']['name'].lower(
            ) == 'steam':
                game_type = GameType.Steam
                path, third_party_id = self._get_steam_game_properties_from_yaml(
                    game_yaml)
                status = get_steam_game_status(path)
            elif game_yaml['root']['third_party_platform']['name'].lower(
            ) == 'origin':
                log.info(f"Origin game found {game_yaml}")
                # game_type = GameType.Origin
                # path = game_yaml['root']['third_party_platform']['platform_installation_status']['register']
                # todo status = _return_origin_game_status(path)
        else:
            try:
                special_registry_path, exe = self._get_registry_properties_from_yaml(
                    game_yaml)
            except Exception as e:
                log.info(
                    f"Unable to read registry path for game {launch_id}: {repr(e)}"
                )

            path = get_local_game_path(special_registry_path, launch_id)
            if path:
                status = get_game_installed_status(path, exe,
                                                   special_registry_path)

        game_name = self._get_game_name_from_yaml(game_yaml)

        log.info(
            f"Parsed game from configuration {space_id}, {install_id}, {game_name}, {launch_id}"
        )
        return UbisoftGame(space_id=space_id,
                           launch_id=launch_id,
                           install_id=install_id,
                           third_party_id=third_party_id,
                           name=game_name,
                           path=path,
                           type=game_type,
                           special_registry_path=special_registry_path,
                           exe=exe,
                           status=status)
예제 #2
0
    async def _parse_club_games(self):
        if not self.parsing_club_games:
            try:
                self.parsing_club_games = True
                games = await self.client.get_club_titles()
                club_games = []
                for game in games:
                    if "platform" in game:
                        if game["platform"] == "PC":
                            log.info(
                                f"Parsed game from Club Request {game['title']}"
                            )
                            club_games.append(
                                UbisoftGame(space_id=game['spaceId'],
                                            launch_id='',
                                            install_id='',
                                            third_party_id='',
                                            name=game['title'],
                                            path='',
                                            type=GameType.New,
                                            special_registry_path='',
                                            exe='',
                                            status=GameStatus.Unknown,
                                            owned=True))
                        else:
                            log.debug(
                                f"Skipped game from Club Request for {game['platform']}: {game['spaceId']}, {game['title']}"
                            )

                self.games_collection.extend(club_games)
            except ApplicationError as e:
                log.error(
                    f"Encountered exception while parsing club games {repr(e)}"
                )
                raise e
            except Exception as e:
                log.error(
                    f"Encountered exception while parsing club games {repr(e)}"
                )
            finally:
                self.parsing_club_games = False
        else:
            # Wait until club games get parsed if parsing is already in progress
            while self.parsing_club_games:
                await asyncio.sleep(0.2)
예제 #3
0
 async def _parse_subscription_games(self):
     subscription_games = []
     sub_response = await self.client.get_subscription()
     if not sub_response:
         return
     for game in sub_response['games']:
         subscription_games.append(
             UbisoftGame(space_id='',
                         launch_id=str(game['uplayGameId']),
                         install_id=str(game['uplayGameId']),
                         third_party_id='',
                         name=game['name'],
                         path='',
                         type=GameType.New,
                         special_registry_path='',
                         exe='',
                         status=GameStatus.Unknown,
                         owned=game['ownership'],
                         activation_id=str(game['id'])))
     self.games_collection.extend(subscription_games)
예제 #4
0
    def _parse_game(self, game_yaml, launch_id):
        path = ''
        space_id = ''
        third_party_id = ''
        special_registry_path = ''
        status = GameStatus.NotInstalled
        game_type = GameType.New
        game_name = ''
        exe = ''
        launch_id = str(launch_id)

        if 'space_id' in game_yaml['root']:
            space_id = game_yaml['root']['space_id']
        else:
            game_type = GameType.Legacy

        if 'third_party_platform' in game_yaml['root']:
            if game_yaml['root']['third_party_platform']['name'].lower(
            ) == 'steam':
                game_type = GameType.Steam
                path = game_yaml['root']['start_game']['steam'][
                    'game_installation_status_register']
                status = get_steam_game_status(path)
                if 'start_game' in game_yaml['root']:
                    if 'steam' in game_yaml['root']['start_game']:
                        third_party_id = game_yaml['root']['start_game'][
                            'steam']['steam_app_id']
            elif game_yaml['root']['third_party_platform']['name'].lower(
            ) == 'origin':
                game_type = GameType.Origin
                path = game_yaml['root']['third_party_platform'][
                    'platform_installation_status']['register']
                # todo status = _return_origin_game_status(path)
        else:
            try:
                registry_path = game_yaml['root']['start_game']['online'][
                    'executables'][0]['working_directory']['register']
                if "Uninstall" in registry_path:
                    registry_path = registry_path.split(
                        "HKEY_LOCAL_MACHINE\\")[1]
                    registry_path = registry_path.split("\\InstallLocation")[0]
                    special_registry_path = registry_path
                    exe = game_yaml['root']['start_game']['online'][
                        'executables'][0]['path']['relative']
            except Exception as e:
                log.info(
                    f"Unable to read registry path for game {launch_id}: {repr(e)}"
                )

            path = _smart_return_local_game_path(special_registry_path,
                                                 launch_id)
            if path:
                status = _return_game_installed_status(path, exe,
                                                       special_registry_path)

        if 'name' in game_yaml['root']:
            game_name = game_yaml['root']['name']
        # Fallback 1
        if game_name.lower() in UBISOFT_CONFIGURATIONS_BLACKLISTED_NAMES:
            if 'installer' in game_yaml[
                    'root'] and 'game_identifier' in game_yaml['root'][
                        'installer']:
                game_name = game_yaml['root']['installer']['game_identifier']
        # Fallback 2
        if game_name.lower() in UBISOFT_CONFIGURATIONS_BLACKLISTED_NAMES:
            if 'localizations' in game_yaml and 'default' in game_yaml['localizations'] and 'GAMENAME' in \
                    game_yaml['localizations']['default']:
                game_name = game_yaml['localizations']['default']['GAMENAME']

        log.info(
            f"Parsed game from configuration {space_id}, {launch_id}, {game_name}"
        )
        return UbisoftGame(space_id=space_id,
                           launch_id=launch_id,
                           third_party_id=third_party_id,
                           name=game_name,
                           path=path,
                           type=game_type,
                           special_registry_path=special_registry_path,
                           exe=exe,
                           status=status)