Exemplo n.º 1
0
        internal List <GameInfo> GetLibraryGames(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                throw new Exception("Steam user name cannot be empty.");
            }

            var games         = new List <GameInfo>();
            var importedGames = servicesClient.GetSteamLibrary(userName);

            if (importedGames == null)
            {
                throw new Exception("No games found on specified Steam account.");
            }

            IDictionary <string, DateTime> lastActivity = null;

            if (ulong.TryParse(userName, out var userId))
            {
                try
                {
                    lastActivity = GetGamesLastActivity(userId);
                }
                catch (Exception exc)
                {
                    logger.Warn(exc, "Failed to import Steam last activity.");
                }
            }

            foreach (var game in importedGames)
            {
                // Ignore games without name, like 243870
                if (string.IsNullOrEmpty(game.name))
                {
                    continue;
                }

                var newGame = new GameInfo()
                {
                    GameId           = game.appid.ToString(),
                    Source           = "Steam",
                    Name             = game.name,
                    Playtime         = game.playtime_forever * 60,
                    CompletionStatus = game.playtime_forever > 0 ? CompletionStatus.Played : CompletionStatus.NotPlayed
                };

                if (lastActivity != null && lastActivity.TryGetValue(newGame.GameId, out var gameLastActivity))
                {
                    newGame.LastActivity = gameLastActivity;
                }

                games.Add(newGame);
            }

            return(games);
        }
Exemplo n.º 2
0
        internal List <GameInfo> GetLibraryGames(SteamLibrarySettings settings)
        {
            if (settings.UserId.IsNullOrEmpty())
            {
                throw new Exception(PlayniteApi.Resources.GetString("LOCNotLoggedInError"));
            }

            var userId = ulong.Parse(settings.UserId);

            if (settings.IsPrivateAccount)
            {
                return(GetLibraryGames(userId, GetPrivateOwnedGames(userId, LibrarySettings.ApiKey, LibrarySettings.IncludeFreeSubGames)?.response?.games));
            }
            else
            {
                return(GetLibraryGames(userId, ServicesClient.GetSteamLibrary(userId, LibrarySettings.IncludeFreeSubGames)));
            }
        }
Exemplo n.º 3
0
        internal List <Game> GetLibraryGames(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                throw new Exception("Steam user name cannot be empty.");
            }

            var games         = new List <Game>();
            var importedGames = servicesClient.GetSteamLibrary(userName);

            if (importedGames == null)
            {
                throw new Exception("No games found on specified Steam account.");
            }

            foreach (var game in importedGames)
            {
                // Ignore games without name, like 243870
                if (string.IsNullOrEmpty(game.name))
                {
                    continue;
                }

                var newGame = new Game()
                {
                    PluginId         = Id,
                    GameId           = game.appid.ToString(),
                    Source           = "Steam",
                    Name             = game.name,
                    Playtime         = game.playtime_forever * 60,
                    CompletionStatus = game.playtime_forever > 0 ? CompletionStatus.Played : CompletionStatus.NotPlayed
                };

                games.Add(newGame);
            }

            return(games);
        }