コード例 #1
0
ファイル: OriginLibrary.cs プロジェクト: shendrix/Playnite
        public List <IGame> GetLibraryGames()
        {
            using (var api = new WebApiClient())
            {
                if (api.GetLoginRequired())
                {
                    throw new Exception("User is not logged in.");
                }

                var token = api.GetAccessToken();
                if (token == null)
                {
                    throw new Exception("Failed to get access to user account.");
                }

                if (!string.IsNullOrEmpty(token.error))
                {
                    throw new Exception("Access error: " + token.error);
                }

                var info = api.GetAccountInfo(token);
                if (!string.IsNullOrEmpty(info.error))
                {
                    throw new Exception("Access error: " + info.error);
                }

                var games = new List <IGame>();

                foreach (var game in api.GetOwnedGames(info.pid.pidId, token).Where(a => a.offerType == "basegame"))
                {
                    games.Add(new Game()
                    {
                        Provider   = Provider.Origin,
                        ProviderId = game.offerId,
                        Name       = game.offerId
                    });
                }

                return(games);
            }
        }