Skip to content

Commit 97a791c

Browse files
authored
Update rushstats.py
1 parent 25a8c39 commit 97a791c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

rushstats.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22
import requests
33

44
def session(token):
5-
global headers
5+
global headers, url
6+
url = 'https://api.rushstats.com/v1/'
67
headers = {'Authorization': token}
78

89
def get_player(tag):
9-
return requests.get('https://api.rushstats.com/v1/player/' + tag, headers=headers).json()
10+
return getdata('player/', tag)
1011

1112
def get_team(tag):
12-
return requests.get('https://api.rushstats.com/v1/team/' + tag, headers=headers).json()
13+
return getdata('team/', tag)
1314

1415
def team_search(keyword):
15-
return requests.get('https://api.rushstats.com/v1/search/team/' + keyword, headers=headers).json()
16+
return getdata('search/team/', keyword)
1617

1718
def top_players(count):
18-
return requests.get('https://api.rushstats.com/v1/leaderboard/players?count=' + str(count), headers=headers).json()
19+
return getdata('leaderboard/players?count=', count)
20+
21+
def getdata(end, arg):
22+
if 'headers' in globals():
23+
return requests.get(url + end + str(arg), headers=headers).json()
24+
else:
25+
print('Please authenticate using your token!')

0 commit comments

Comments
 (0)