-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.py
More file actions
53 lines (46 loc) · 2.01 KB
/
server.py
File metadata and controls
53 lines (46 loc) · 2.01 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
53
# -*- coding: utf-8 -*-
import sys
import time
from datetime import datetime, timezone
import threading
from resources.lib.web import start_server
from resources.lib.epg import load_epg
from resources.lib.utils import is_kodi, get_config_value, log_message
class BottleThreadClass(threading.Thread):
def run(self):
start_server()
if is_kodi() == True:
time.sleep(20)
bt = BottleThreadClass()
bt.start()
tz_offset = int(datetime.now(timezone.utc).astimezone().utcoffset().total_seconds() / 3600)
if int(get_config_value('interval_stahovani_epg')) == 0:
sys.exit()
next = time.time() + 10
if is_kodi() == True:
import xbmc
while not xbmc.Monitor().abortRequested():
if(next < time.time()):
time.sleep(3)
if get_config_value('username') and len(get_config_value('username')) > 0 and get_config_value('password') and len(get_config_value('password')) > 0:
if int(get_config_value('interval_stahovani_epg')) > 0:
load_epg(reset = True)
interval = int(get_config_value('interval_stahovani_epg'))*60
next = time.time() + float(interval)
time.sleep(1)
else:
try:
log_message('Start plánovače pro stahování EPG\n')
while True:
if(next < time.time()):
time.sleep(3)
if get_config_value('username') and len(get_config_value('username')) > 0 and get_config_value('password') and len(get_config_value('password')) > 0:
if int(get_config_value('interval_stahovani_epg')) > 0:
log_message('Začátek stahování EPG\n')
load_epg(reset = True)
log_message('Konec stahování EPG\n')
interval = int(get_config_value('interval_stahovani_epg'))*60*60
next = time.time() + float(interval)
time.sleep(1)
except KeyboardInterrupt:
log_message('Ukončení plánovače pro stahování EPG\n')