-
Notifications
You must be signed in to change notification settings - Fork 0
/
verifierFULLupdater.py
146 lines (137 loc) · 5.55 KB
/
verifierFULLupdater.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import requests, json, time
src = "https://www.speedrun.com/api/v1/"
import mods
with open("vdatabase.json", "r") as f:
fjson = json.loads(f.readlines()[0])
#with open("outputs/verifieroutput.txt", "w") as v:
# v.truncate(0)
no = 0
usersid = ""
t = time.time()
fjsonk = list(fjson.keys())[:] #list(fjson.keys()).index("86n5knqx")
while True:
if usersid != "":
fjsonk = list(fjson.keys())[list(fjson.keys()).index(usersid):]
print(usersid)
try:
for user in fjsonk:
usersid = user
print(fjson[user][0], len(list(fjson.keys()))-list(fjson.keys()).index(user))
if fjson[user][0] in ["dha", "1", "Reni", "jensj56"]:
continue
while True:
no += 1
try:
if time.time() - t < 0.8:
time.sleep(0.8 - (time.time() - t))
o1600 = requests.get(src + f"runs?examiner={user}&max=1&offset=1600").json()
t = time.time()
if "status" in list(o1600.keys()):
if o1600["status"] == 404:
o1600 = []
break
else:
print("We're getting rate limited!", o1600["status"])
time.sleep(10)
continue
o1600 = o1600["data"]
break
except Exception:
if "status" in list(o1600.keys()):
if o1600["status"] == 404:
o1600 = []
break
else:
print("We're getting rate limited!", o1600["status"], "test")
time.sleep(10)
continue
if len(o1600) == 0:
continue
allruns = []
lastrun = {"id": "whadohdwao///"}
breakeverything = False
deleted = False
for dir in ["asc", "desc"]:
offset = 0
while offset < 10000:
while True:
try:
if time.time() - t < 0.8:
time.sleep(0.8 - (time.time() - t))
runs = requests.get(src + f"runs?examiner={user}&direction={dir}&max=200&offset={offset}&orderby=date").json()
t = time.time()
if "status" in list(runs.keys()):
if runs["status"] == 404:
deleted = True
break
else:
print("We're getting rate limited!")
time.sleep(10)
continue
break
except Exception:
print("We're getting rate limited!")
time.sleep(10)
continue
if deleted:
break
runs = runs["data"]
for run in runs:
if len(run["players"]) > 0:
if run["players"][0]["rel"] == "guest":
if run["players"][0]["name"].lower() == "n/a" or run["players"][0]["name"].lower() == "n\a":
continue
else:
continue
if run["id"] == lastrun["id"]:
breakeverything = True
break
allruns.append(run)
if len(runs) < 200 or breakeverything:
break
offset += 200
if offset != 10000:
break
lastrun = allruns[-1]
print(len(allruns))
with open("outputs/verifieroutput.txt", "a") as f:
if deleted:
continue
else:
f.writelines(f"{user}, {len(allruns)}\n")
break
except Exception:
continue
# 1DHARENI
time.sleep(30)
import onedhareni
# LEADERBOARD
with open("outputs/verifieroutput.txt", "r") as o:
output = "".join(o.readlines())
lb = {}
for i in output.split("\n"):
lb.update({i.split(", ")[0]: int(i.split(", ")[1])})
with open("outputs/verifierfinallb.txt", "a") as flb:
flb.truncate(0)
nr, no, ibefore = 1, 1, []
print(list(dict(sorted(lb.items(), key=lambda item: item[1], reverse=True)).keys()))
for i in list(dict(sorted(lb.items(), key=lambda item: item[1], reverse=True)).keys()):
with open("vdatabase.json", "r") as datab:
if lb[i] != ibefore:
no = nr
database = json.loads(datab.readlines()[0])
flb.writelines(f'`{no}.`{database[i][1]}`{database[i][0]}' + " "*(27-(len(f"{no}"))-(len(str(lb[i]))+len(database[i][0]))) + f'{lb[i]}`\n')
nr+=1
ibefore = lb[i]
# CLEAN UP
newdatabase = {}
with open("vdatabase.json", "r") as f:
f = f.readlines()[0]
f = json.loads(f)
with open("outputs/verifieroutput.txt", "r") as o:
o = "".join(o.readlines())
for i in list(f.keys()):
if i in o:
newdatabase.update({i: [f[i][0], f[i][1]]})
with open("vdatabase.json", "w") as data:
data.writelines(json.dumps(newdatabase))