Showing
4 changed files
with
68 additions
and
9 deletions
... | @@ -9,12 +9,14 @@ headers={ | ... | @@ -9,12 +9,14 @@ headers={ |
9 | "Origin": "https://developer.riotgames.com", | 9 | "Origin": "https://developer.riotgames.com", |
10 | "X-Riot-Token": APIKEY | 10 | "X-Riot-Token": APIKEY |
11 | } | 11 | } |
12 | -API="https://kr.api.riotgames.com/lol/summoner/v4/summoners/by-name/" + name | ||
13 | -getAPI=requests.get(API, headers=headers) | ||
14 | -LOL_API_DATA=getAPI.json() | ||
15 | def get_account_id(): | 12 | def get_account_id(): |
13 | + API="https://kr.api.riotgames.com/lol/summoner/v4/summoners/by-name/" + name | ||
14 | + getAPI=requests.get(API, headers=headers) | ||
15 | + LOL_API_DATA=getAPI.json() | ||
16 | return LOL_API_DATA["accountId"] | 16 | return LOL_API_DATA["accountId"] |
17 | def return_key(): | 17 | def return_key(): |
18 | return APIKEY | 18 | return APIKEY |
19 | def return_name(): | 19 | def return_name(): |
20 | return name | 20 | return name |
21 | + | ||
22 | + | ... | ... |
... | @@ -16,3 +16,4 @@ def get_game_id(index): | ... | @@ -16,3 +16,4 @@ def get_game_id(index): |
16 | return LOL_API_DATA[index].get("gameId") | 16 | return LOL_API_DATA[index].get("gameId") |
17 | def get_champ_id(index): | 17 | def get_champ_id(index): |
18 | return LOL_API_DATA[index].get("champion") | 18 | return LOL_API_DATA[index].get("champion") |
19 | + | ... | ... |
check_score.py
0 → 100644
1 | +import Get_Account_Id | ||
2 | +import Get_Game_Id | ||
3 | +import requests | ||
4 | +APIKEY=Get_Account_Id.return_key() | ||
5 | +headers = { | ||
6 | + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36", | ||
7 | + "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", | ||
8 | + "Accept-Charset": "application/x-www-form-urlencoded; charset=UTF-8", | ||
9 | + "Origin": "https://developer.riotgames.com", | ||
10 | + "X-Riot-Token": APIKEY | ||
11 | + } | ||
12 | +def op_score(ac_id): | ||
13 | + API="https://kr.api.riotgames.com/lol/match/v4/matchlists/by-account/" + ac_id | ||
14 | + getAPI=requests.get(API, headers=headers) | ||
15 | + DATA=getAPI.json()["matches"] | ||
16 | + score=0 | ||
17 | + for i in range(0,5): | ||
18 | + score+=first_step(DATA[i].get("gameId"),ac_id) | ||
19 | + return score | ||
20 | + | ||
21 | +def first_step(gameid,ac_id): | ||
22 | + API="https://kr.api.riotgames.com/lol/match/v4/matches/" + str(gameid) | ||
23 | + print(gameid) | ||
24 | + getAPI=requests.get(API, headers=headers) | ||
25 | + f_step_api=getAPI.json() | ||
26 | + t_score=0 | ||
27 | + for i in range(0,10): | ||
28 | + if (f_step_api["participantIdentities"][i]["player"]["accountId"]==ac_id): | ||
29 | + if f_step_api["participants"][i]["stats"]["deaths"]==0: | ||
30 | + t_score=round((f_step_api["participants"][i]["stats"]["kills"]*3+f_step_api["participants"][i]["stats"]["assists"]*0.5)/\ | ||
31 | + 1,2)+round(f_step_api["participants"][i]["stats"]["totalMinionsKilled"]\ | ||
32 | + /(f_step_api["gameDuration"]/60)*0.2,2)+round(f_step_api["participants"][i]["stats"]["visionScore"]*0.05,2) | ||
33 | + else: | ||
34 | + t_score=round((f_step_api["participants"][i]["stats"]["kills"]*3+f_step_api["participants"][i]["stats"]["assists"]*0.5)/\ | ||
35 | + (f_step_api["participants"][i]["stats"]["deaths"]*3),2)+round(f_step_api["participants"][i]["stats"]["totalMinionsKilled"]\ | ||
36 | + /(f_step_api["gameDuration"]/60)*0.2,2)+round(f_step_api["participants"][i]["stats"]["visionScore"]*0.05,2) | ||
37 | + i=10 | ||
38 | + return t_score | ||
39 | + |
1 | import Get_Account_Id | 1 | import Get_Account_Id |
2 | import Get_Game_Id | 2 | import Get_Game_Id |
3 | +import check_score | ||
3 | import requests | 4 | import requests |
4 | APIKEY=Get_Account_Id.return_key() | 5 | APIKEY=Get_Account_Id.return_key() |
5 | -name=Get_Account_Id.return_name().replace(" ","").lower() | ||
6 | headers = { | 6 | headers = { |
7 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36", | 7 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36", |
8 | "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", | 8 | "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", |
... | @@ -16,7 +16,6 @@ def game_result(num): | ... | @@ -16,7 +16,6 @@ def game_result(num): |
16 | API="https://kr.api.riotgames.com/lol/match/v4/matches/" + str(gameid) | 16 | API="https://kr.api.riotgames.com/lol/match/v4/matches/" + str(gameid) |
17 | getAPI=requests.get(API, headers=headers) | 17 | getAPI=requests.get(API, headers=headers) |
18 | LOL_API_DATA=getAPI.json() | 18 | LOL_API_DATA=getAPI.json() |
19 | - find_user=-1 | ||
20 | result=" " | 19 | result=" " |
21 | for i in range(0,10): | 20 | for i in range(0,10): |
22 | if LOL_API_DATA["participants"][i]["championId"]==champid: | 21 | if LOL_API_DATA["participants"][i]["championId"]==champid: |
... | @@ -24,8 +23,26 @@ def game_result(num): | ... | @@ -24,8 +23,26 @@ def game_result(num): |
24 | result="승리" | 23 | result="승리" |
25 | else: | 24 | else: |
26 | result="패배" | 25 | result="패배" |
27 | - print(result) | 26 | + return result |
28 | 27 | ||
29 | - | 28 | +def match_user_name_and_opscore(num): |
30 | -for j in range(0,10): | 29 | + gameid=Get_Game_Id.get_game_id(num) |
31 | - game_result(j) | 30 | + API="https://kr.api.riotgames.com/lol/match/v4/matches/" + str(gameid) |
31 | + getAPI=requests.get(API, headers=headers) | ||
32 | + LOL_API_DATA=getAPI.json() | ||
33 | + record_name=[] | ||
34 | + record_opscore=[] | ||
35 | + for i in range(0,10): | ||
36 | + record_name.append(LOL_API_DATA["participantIdentities"][i]["player"]["summonerName"]) | ||
37 | + print(record_name) | ||
38 | + ac_id=LOL_API_DATA["participantIdentities"][i]["player"]["accountId"] | ||
39 | + record_opscore.append(check_score.op_score(ac_id)) | ||
40 | + print(record_opscore) | ||
41 | + return record_name,record_opscore | ||
42 | +for j in range(0,10): | ||
43 | + print(game_result(j)) | ||
44 | + lst1=[] | ||
45 | + lst2=[] | ||
46 | + lst1,lst2=match_user_name_and_opscore(j) | ||
47 | + print(lst1) | ||
48 | + print(lst2) | ... | ... |
-
Please register or login to post a comment