-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFetchMatchIds.py
76 lines (61 loc) · 2.86 KB
/
FetchMatchIds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from RIOTAPI import RIOTAPI, MajorRegion, QueueType, Server
from LeagueRequester import LeagueRequester
from MatchRequester import MatchRequester
from SummonerRequester import SummonerRequester
import progressbar
import sys
# Fetch enctyped PUUIDs from a league entry
def FetchEncryptedPUUIDs(api : RIOTAPI, server : Server, leagueEntries : dict):
#Get their summoner names
summonerEntries = leagueEntries["entries"]
summonerIds = []
for entry in summonerEntries:
summonerIds.append(entry["summonerId"])
#Convert the summoner Ids into encrypted puuids
summonerRequester = SummonerRequester(api)
summonerPUUIDs = []
widgets = ['[', progressbar.Counter(format='%(value)02d/%(max_value)d'), ']','[', progressbar.Timer(format="Elapsed Time: %(elapsed)s"), ']', progressbar.Bar('*')]
for i in progressbar.progressbar(range(len(summonerIds)), widgets=widgets):
id = summonerIds[i]
summoner = summonerRequester.RequestByEncrypedSummonerID(server, id)
summonerPUUIDs.append(summoner["puuid"])
return summonerPUUIDs
api = RIOTAPI(sys.argv[1])
matchRequester = MatchRequester(api)
leagueRequester = LeagueRequester(api)
region = MajorRegion.AMERICAS
server = Server.NA
queueType = QueueType.Ranked5x5
print()
print("Region: {}".format(region.value))
print("Server: {}".format(server.value))
print("Queue Type: {}".format(queueType))
#Get the high elo players
leagueRequester = LeagueRequester(api)
encryptedPUUIDs = []
print("\nFetch Challenger Encrypted PUUIDS")
challengerPUUIDs = FetchEncryptedPUUIDs(api, server, leagueRequester.RequestChallengerPlayers(server))
encryptedPUUIDs.extend(challengerPUUIDs)
#print("\nFetch Grandmaster Encrypted PUUIDS")
#grandmasterPUUIDs = FetchEncryptedPUUIDs(api, server, leagueRequester.RequestGrandmasterPlayers(server))
#encryptedPUUIDs.extend(grandmasterPUUIDs)
#print("\nFetch Master Encrypted PUUIDS")
#masterPUUIDs = FetchEncryptedPUUIDs(api, server, leagueRequester.RequestMasterPlayers(server))
#encryptedPUUIDs.extend(masterPUUIDs)
print()
print("Total Challenger Count: {}".format(len(challengerPUUIDs)))
#print("Total Grandmaster Count: {}".format(len(grandmasterPUUIDs)))
#print("Total Master Count: {}".format(len(masterPUUIDs)))
print("Total Player Count: {}".format(len(encryptedPUUIDs)))
print("\nFetch Player Match IDs")
matchIDs = set()
widgets = ['[', progressbar.Counter(format='%(value)02d/%(max_value)d'), ']', progressbar.Timer(format="Elapsed Time: %(elapsed)s"), ']', progressbar.Bar('*')]
for i in progressbar.progressbar(range(len(encryptedPUUIDs)), widgets=widgets):
puuid = encryptedPUUIDs[i]
matches = matchRequester.RequestMatchIds(region, puuid, 0, 100, queueType)
matchIDs.update(matches)
print()
print("Total Match Count: {}".format(len(matchIDs)))
with open("MatchIds.txt", "w") as matchFile:
for id in matchIDs:
matchFile.write("{}\n".format(id))