-
Notifications
You must be signed in to change notification settings - Fork 2
/
leaderboards.py
executable file
·83 lines (66 loc) · 3.42 KB
/
leaderboards.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
77
78
79
80
81
82
83
import requests
import sys
user_in = input("Enter a region code (eu, na, kr, ap): ")
region = user_in.lower()
r = requests.get(f"https://api.henrikdev.xyz/valorant/v1/leaderboard/{region}")
json_data = r.json()
def getUser(name):
users = ""
for s in range(len(json_data)):
if name.lower() in str(json_data[s]['gameName'] + "#" + json_data[s]['tagLine']).lower():
users += str(json_data[s]['leaderboardRank']) + ". " + json_data[s]['gameName'] + "#" + json_data[s]['tagLine'] + " | RR: " + str(json_data[s]['rankedRating']) +" | Wins: " + str(json_data[s]['numberOfWins']) + "\n"
return users.rstrip()
def getUserOfRank(rank):
for s in range(len(json_data)):
if str(rank) in str(json_data[s]['leaderboardRank']):
if not json_data[s]['gameName'] and not json_data[s]['tagLine']:
return (str(json_data[s]['leaderboardRank']) + ". " + "Secret Agent" + " | RR: " + str(json_data[s]['rankedRating']) +" | Wins: " + str(json_data[s]['numberOfWins']))
else:
return (str(json_data[s]['leaderboardRank']) + ". " + json_data[s]['gameName'] + "#" + json_data[s]['tagLine'] + " | RR: " + str(json_data[s]['rankedRating']) +" | Wins: " + str(json_data[s]['numberOfWins']))
def getTopX(topx):
text = ""
for s in range(topx):
if not json_data[s]['gameName'] and not json_data[s]['tagLine']:
text += str(json_data[s]['leaderboardRank']) + ". " + "Secret Agent" + " | RR: " + str(json_data[s]['rankedRating']) +" | Wins: " + str(json_data[s]['numberOfWins']) + "\n"
else:
text += str(json_data[s]['leaderboardRank']) + ". " + json_data[s]['gameName'] + "#" + json_data[s]['tagLine'] + " | RR: " + str(json_data[s]['rankedRating']) +" | Wins: " + str(json_data[s]['numberOfWins']) + "\n"
return text[:-1]
def listLeaderboard():
for s in range(len(json_data)):
if not json_data[s]['gameName'] and not json_data[s]['tagLine']:
print(str(json_data[s]['leaderboardRank']) + ". " + "Secret Agent" + " | RR: " + str(json_data[s]['rankedRating']) +" | Wins: " + str(json_data[s]['numberOfWins']))
else:
print(str(json_data[s]['leaderboardRank']) + ". " + json_data[s]['gameName'] + "#" + json_data[s]['tagLine'] + " | RR: " + str(json_data[s]['rankedRating']) +" | Wins: " + str(json_data[s]['numberOfWins']))
def noCLI():
print("")
print("If you want to see the whole leaderboard list -> l\n"
"If you want to search a specific user -> u\n"
"If you want to get the info for a specific rank number -> n\n"
"If you want to list the top x players -> t"
)
check = input("[l/u/n/t]: ").lower()
if check == "u":
name = input("Enter user name without tag: ")
print(getUser(name))
if check == "n":
rank = input("Enter rank number (eg. 500): ")
print(getUserOfRank(rank))
if check == "t":
topx = int(input("Enter how many players to list number (eg. 10): "))
print(getTopX(topx))
if check == "l":
listLeaderboard()
if len(sys.argv) > 1:
if sys.argv[1] == "--list":
listLeaderboard()
if sys.argv[1] == "--search":
name = sys.argv[2]
print(getUser(name))
if sys.argv[1] == "--rank":
rank = sys.argv[2]
print(getUserOfRank(rank))
if sys.argv[1] == "--top":
topx = int(sys.argv[2])
print(getTopX(topx))
else:
noCLI()