This repository was archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathretrieve.py
More file actions
78 lines (68 loc) · 2.65 KB
/
retrieve.py
File metadata and controls
78 lines (68 loc) · 2.65 KB
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
77
78
# @author: Fred Lee
from RiotAPI import RiotAPI
from imported import imported
import API_KEY as API_KEY
import time
import json
from pprint import pprint
def main():
importe = imported()
summoners = importe.request_summoners()
spells = importe.request_spells()
banned_Champions = importe.request_banned_Champions()
picked_Champions = importe.request_picked_Champions()
static = RiotAPI(API_KEY.key, 'global')
s = static.get_champion_to_id()
id_to_champs = {}
for champ in s['data']:
id_to_champs[s['data'][champ]['id']] = str(s['data'][champ]['name'])
# summoners = {}
# spells = {}
# banned_Champions = {}
# picked_Champions = {}
id_to_spells = {
11 : "Smite", 12 : "Teleport", 14 : "Ignite", 3 : "Exhaust", 4 : "Flash", 7 : "Heal",
21 : "Barrier", 1 : "Cleanse", 6 : "Ghost", 32 : "Mark", 13 : "Clarity", 2 : "Clairvoyance"
}
# # seconds * # minutes * # hours
t_end = time.time() + 60 * 1 * 1
while time.time() < t_end:
api = RiotAPI(API_KEY.key)
r = api.get_featured_game()
if (r.has_key('status')):
print r
else:
for game in r['gameList']:
for player in game['participants']:
if summoners.has_key(player['summonerName']):
summoners[player['summonerName']] += 1
else:
summoners[player['summonerName']] = 1
if spells.has_key(id_to_spells[player['spell1Id']]):
spells[id_to_spells[player['spell1Id']]] += 1
else:
spells[id_to_spells[player['spell1Id']]] = 1
if spells.has_key(id_to_spells[player['spell2Id']]):
spells[id_to_spells[player['spell2Id']]] += 1
else:
spells[id_to_spells[player['spell2Id']]] = 1
if picked_Champions.has_key(id_to_champs[player['championId']]):
picked_Champions[id_to_champs[player['championId']]] += 1
else:
picked_Champions[id_to_champs[player['championId']]] = 1
for bannedChamps in game['bannedChampions']:
if banned_Champions.has_key(id_to_champs[bannedChamps['championId']]):
banned_Champions[id_to_champs[bannedChamps['championId']]] += 1
else:
banned_Champions[id_to_champs[bannedChamps['championId']]] = 1
time.sleep(60)
with open('Data/summonerData.json', 'w') as outfile:
json.dump(sorted(summoners.items(), key=lambda x: x[1], reverse=True), outfile)
with open('Data/bannedData.json', 'w') as outfile:
json.dump(sorted(banned_Champions.items(), key=lambda x: x[1], reverse=True), outfile)
with open('Data/pickedData.json', 'w') as outfile:
json.dump(sorted(picked_Champions.items(), key=lambda x: x[1], reverse=True), outfile)
with open('Data/spellData.json', 'w') as outfile:
json.dump(sorted(spells.items(), key=lambda x: x[1], reverse=True), outfile)
if __name__ == "__main__":
main()