-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (42 loc) · 1.21 KB
/
main.py
File metadata and controls
52 lines (42 loc) · 1.21 KB
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
import requests
import tkinter
import time
import math
url = "http://www.tudbut.de/api"
playTimeUrl = "/getOverallPlaytime"
userRecordUrl = "/getUserRecordByName"
def getOverallPlaytime():
print("getting pt")
response = requests.get(str(url + playTimeUrl))
print("got")
return response
def getOnlineUsers(delay):
pt1 = getOverallPlaytime().content
time.sleep(delay)
pt2 = getOverallPlaytime().content
players = math.ceil(int(pt2)-int(pt1))/delay
return players
def getPlayerData(username):
response = requests.get(url + userRecordUrl + "?name=" + username)
response = split(response.text)
return response
def getUUID(username):
response = requests.get(url + "/getUUID?name=" + username)
return response
def getName(UUID):
response = requests.get(url + "/getName?uuid=" + UUID)
return response
def split(data):
list = data.split("\n")
list2 = []
for i in list:
a = i.split(":")
for b in a:
list2.append(b)
it = iter(list2)
res_dct = dict(zip(it, it))
return res_dct
def sendLogin(UUID):
requests.post(url + "/track/login?uuid=" + UUID)
def sendPlay(UUID):
requests.post(url + "/track/play?uuid=" + UUID)