예제 #1
0
        public MatchHistory GetMatchHistory(int begIndex = 0, int endIndex = 15)
        {
            RestRequest request = new RestRequest("http://matchhistory.na.leagueoflegends.com/en/");

            request.AddHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
            request.AddHeader("Accept-Encoding", "gzip, deflate");
            request.AddHeader("Upgrade-Insecure-Requests", "1");
            request.AddHeader("Referer", "https://na.leagueoflegends.com/");
            request.AddHeader("Host", "matchhistory.na.leagueoflegends.com");

            Parameter beg = new Parameter();

            beg.Name  = "begIndex";
            beg.Value = begIndex;
            beg.Type  = ParameterType.QueryString;

            Parameter end = new Parameter();

            end.Name  = "endIndex";
            end.Value = endIndex;
            end.Type  = ParameterType.QueryString;

            if (!setup)
            {
                client.AddDefaultHeader("Origin", "http://matchhistory.na.leagueoflegends.com");
                client.AddDefaultHeader("Referer", "http://matchhistory.na.leagueoflegends.com/en/");
                client.AddDefaultHeader("Host", "acs.leagueoflegends.com");
                setup = true;
            }

            client.BaseUrl = new Uri("https://acs.leagueoflegends.com/v1/");
            request        = new RestRequest("stats/player_history/auth", Method.OPTIONS);
            request.AddHeader("Accept", "*/*");
            request.AddHeader("Access-Control-Request-Headers", "authorization,region");
            request.AddHeader("Access-Control-Request-Method", "GET");
            request.AddParameter(beg);
            request.AddParameter(end);
            client.Execute(request);

            request.Resource = "deltas/auth";
            request.Parameters.RemoveAll(p => p.Name.Contains("Index"));
            client.Execute(request);

            request = new RestRequest("stats/player_history/auth", Method.GET);
            request.AddHeader("Accept", "application/json, text/javascript, */*; q=0.01");
            request.AddHeader("Region", "NA");
            request.AddHeader("Authorization", "Vapor " + this.vaporToken);
            request.AddParameter(beg);
            request.AddParameter(end);
            var          response  = client.Execute(request);
            MatchHistory matchHist = JSON.Deserialize <MatchHistory>(response.Content);

            if (this.gamesCount == 0)
            {
                this.gamesCount = matchHist.games.gameCount;
            }

            return(matchHist);
        }
예제 #2
0
        public List <long> GetGameIDs()
        {
            List <long> gameIds = new List <long>();
            LOLNav      lolnav  = new LOLNav();

            lolnav.Login();
            MatchHistory matchHist = lolnav.GetMatchHistory();

            gameIds.AddRange(matchHist.games.games.Select(g => g.gameId));
            int count = matchHist.games.gameCount;

            for (int i = 16; i <= count; i += 15)
            {
                matchHist = lolnav.GetMatchHistory(i, (count - i >= 15 ? (i + 15) : count));
                gameIds.AddRange(matchHist.games.games.Select(g => g.gameId));
            }

            if (this.backup)
            {
                File.WriteAllLines(MAIN_PATH + "GameIDs.txt", gameIds.Select(g => g.ToString()));
            }

            return(gameIds);
        }