-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcdn.counter.py
More file actions
executable file
·35 lines (29 loc) · 979 Bytes
/
cdn.counter.py
File metadata and controls
executable file
·35 lines (29 loc) · 979 Bytes
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
import requests
import time
counter = None
averageCounter = None
averageCounterN = 1
fansCounter = open("cdnlogger.txt", "a")
try:
while True:
time.sleep(1)
beforeCounter = counter
counter = requests.get("https://cdn.mindustry.me/research/botindex").text.count("\n")
if beforeCounter is None:
beforeCounter = counter
diff = counter - beforeCounter
if averageCounter is None and diff != 0:
averageCounter = diff
elif averageCounter is not None:
averageCounter = (averageCounter * averageCounterN + diff) / (averageCounterN+1)
averageCounterN = averageCounterN + 1
if diff != 0:
fansCounter.write(str(counter)+"\n")
fansCounter.flush()
print(diff, "/s")
if averageCounter is not None:
print(round(averageCounter, 2), "/s avg")
except Exception as e:
print(e)
print("SAVING")
fansCounter.close()