This repository has been archived by the owner on Aug 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.py
190 lines (158 loc) · 6.02 KB
/
timer.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
from time import sleep
import requests
import os
import sys
sys.stdout.write("\x1b[8;{rows};{cols}t".format(rows=6, cols=42))
def clr():
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
def selectserver():
try:
with open('preferred_server.txt', mode='r') as f:
check = f.read()
gather(check)
except:
server = input(
'Which server are you on?\n1 - EU\n2 - NA\n3 - KR\n4 - SEA\n5 - RU\n\n')
if server == '1':
server = 'eu'
elif server == '2':
server = 'na'
elif server == '3':
server = 'kr'
elif server == '4':
server = 'sea'
elif server == '5':
server = 'ru'
with open('preferred_server.txt', mode='w') as f:
f.write(server)
gather(server)
def gather(server):
try:
sito = requests.get('https://mmotimer.com/bdo/?server='+server)
except:
print('Site is down now.')
testopagina = sito.text
nomiboss = 'Nouver', 'Karanda', 'Kzarka', 'Offin', 'Vell', 'Garmoth', 'Quint', 'Muraka', 'Kutum'
postrading = testopagina.find('Imperial trading reset in:')
trading = testopagina[postrading + 52:postrading + 60]
prossimo = testopagina.find('Next boss')
seguitoda = testopagina.find('Followed by')
trovabosstxt = testopagina[prossimo:seguitoda]
nomeboss2 = ''
occorrenze = 0
for x in nomiboss:
occorrenze = occorrenze + trovabosstxt.count(x)
if occorrenze == 2:
posboss = 0
while posboss == 0:
for b in nomiboss:
posboss = trovabosstxt.find(b)
if posboss == -1:
posboss = 0
else:
break
nomeboss = trovabosstxt[posboss:posboss + 7]
nomeboss = nomeboss.replace('<', '')
nomeboss = nomeboss.replace('/', '')
if nomeboss[:5] == 'Kutum':
nomeboss = 'Kutum'
postboss = trovabosstxt.find('timer countdown">')
tboss = trovabosstxt[postboss + 39:postboss + 47]
tboss = list(tboss)
else:
posboss = 0
while posboss == 0:
for b in nomiboss:
posboss = trovabosstxt.find(b)
if posboss == -1:
posboss = 0
else:
break
nomeboss = trovabosstxt[posboss:posboss + 7]
nomeboss = nomeboss.replace('<', '')
nomeboss = nomeboss.replace('/', '')
if nomeboss[:5] == 'Kutum':
nomeboss = 'Kutum'
postboss = trovabosstxt.find('timer countdown">')
tboss = trovabosstxt[postboss + 39:postboss + 47]
secondo = trovabosstxt[postboss:]
posboss2 = 0
while posboss2 == 0:
for b in nomiboss:
posboss2 = secondo.find(b)
if posboss2 == -1:
posboss2 = 0
else:
break
nomeboss2 = secondo[posboss2:posboss2 + 7]
nomeboss2 = nomeboss2.replace('<', '')
nomeboss2 = nomeboss2.replace('/', '')
if nomeboss2[:5] == 'Kutum':
nomeboss2 = 'Kutum'
hi = hb = int(tboss[1])
mi = mb = int(str((tboss[3]) + (tboss[4])))
si = sb = int(str((tboss[6]) + (tboss[7])))
hba = ht = int(trading[1])
mba = mt = int(str((trading[3]) + (trading[4])))
sba = st = int(str((trading[6]) + (trading[7])))
dnpos = testopagina.find('Night in:') # dnpos = day night position
if dnpos != -1:
orario = testopagina[dnpos + 42:dnpos + 50]
ho = int(orario[1])
mo = int(str((orario[3]) + (orario[4])))
so = int(str((orario[6]) + (orario[7])))
gn = 'Night in: '
countdown(hb, mb, sb, ho, mo, so, hi, mi, si, ht, mt, st,
hba, mba, sba, gn, nomeboss, nomeboss2, server)
gather()
else:
dnpos = testopagina.find('Day in:')
orario = testopagina[dnpos + 40:dnpos + 48]
ho = int(orario[1])
mo = int(str((orario[3]) + (orario[4])))
so = int(str((orario[6]) + (orario[7])))
gn = 'Day in: '
countdown(hb, mb, sb, ho, mo, so, hi, mi, si, ht, mt, st,
hba, mba, sba, gn, nomeboss, nomeboss2, server)
gather()
def hmsToSecs(h, m, s):
return h*3600 + m*60 + s
def secsToHms(secs):
hours = secs//3600
secs -= hours*3600
mins = secs//60
secs -= mins*60
return hours, mins, secs
def countdown(hb, mb, sb, ho, mo, so, hi, mi, si, ht, mt, st, hba, mba, sba, gn, nomeboss, nomeboss2, server):
autoreset = 120
bseconds = hmsToSecs(hb, mb, sb)
oseconds = hmsToSecs(ho, mo, so)
iseconds = hmsToSecs(hi, mi, si)
tseconds = hmsToSecs(ht, mt, st)
baseconds = hmsToSecs(hba, mba, sba)
while bseconds > 0 and oseconds > 0 and iseconds > 0 and tseconds > 0 and baseconds > 0 and autoreset > 0:
clr()
if nomeboss2 != '':
print("Next boss: ", nomeboss, '&', nomeboss2, '\t',
("%02d:%02d:%02d" % secsToHms(bseconds)))
else:
print("Next boss: ", nomeboss, '\t\t',
("%02d:%02d:%02d" % secsToHms(bseconds)))
if gn == 'Day in: ':
print(gn, ' \t\t\t', ("%02d:%02d:%02d" % secsToHms(oseconds)))
else:
print(gn, '\t\t\t', ("%02d:%02d:%02d" % secsToHms(oseconds)))
print("Imperial reset in: \t\t",
("%02d:%02d:%02d" % secsToHms(iseconds)))
print("Imperial trading reset in: \t",
("%02d:%02d:%02d" % secsToHms(baseconds)))
print("Bartering reset in: \t\t",
("%02d:%02d:%02d" % secsToHms(baseconds)))
bseconds, oseconds, iseconds, tseconds, baseconds, autoreset = bseconds - \
1, oseconds-1, iseconds-1, tseconds-1, baseconds-1, autoreset-1
sleep(1)
gather(server)
selectserver()