-
Notifications
You must be signed in to change notification settings - Fork 5
/
service.py
100 lines (78 loc) · 3.27 KB
/
service.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
# coding=utf-8
#
# copyright (C) 2017 Steffen Rolapp ([email protected])
#
# This file is part of zattooHiQ
#
# zattooHiQ is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# zattooHiQ is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with zattooHiQ. If not, see <http://www.gnu.org/licenses/>.
#
import xbmc, xbmcgui, xbmcaddon, datetime, time
import os, urlparse
from resources.library import library
from resources.zattooDB import ZattooDB
_zattooDB_ = ZattooDB()
__addon__ = xbmcaddon.Addon()
_library_=library()
localString = __addon__.getLocalizedString
SWISS = __addon__.getSetting('swiss')
def refreshProg():
import urllib
monitor = xbmc.Monitor()
while not monitor.abortRequested():
if monitor.waitForAbort(600): break
from resources.zattooDB import ZattooDB
_zattooDB_ = ZattooDB()
#update programInfo
startTime=datetime.datetime.now()
endTime=datetime.datetime.now()+datetime.timedelta(minutes = 120)
print 'StartRefresh ' + str(datetime.datetime.now())
try:
getProgNextDay()
_zattooDB_.getProgInfo(False, startTime, endTime)
except:
print 'ERROR on REFRESH'
pass
print "REFRESH Prog " + str(datetime.datetime.now())
def recInfo():
import urllib
resultData = _zattooDB_.zapi.exec_zapiCall('/zapi/playlist', None)
if resultData is None: return
for record in resultData['recordings']:
_zattooDB_.getShowInfo(record['program_id'])
def start():
import urllib
_zattooDB_.cleanProg()
_zattooDB_.updateChannels()
_zattooDB_.updateProgram()
startTime=datetime.datetime.now()#-datetime.timedelta(minutes = 60)
endTime=datetime.datetime.now()+datetime.timedelta(minutes = 20)
xbmcgui.Dialog().notification(localString(31916), localString(30110), __addon__.getAddonInfo('path') + '/icon.png', 3000, False)
_zattooDB_.getProgInfo(True, startTime, endTime)
if SWISS == 'true':
xbmcgui.Dialog().notification(localString(31106), localString(31915), __addon__.getAddonInfo('path') + '/icon.png', 3000, False)
xbmc.executebuiltin("ActivateWindow(busydialog)")
recInfo()
_library_.delete_library() # add by samoth
_library_.make_library()
xbmc.executebuiltin("Dialog.Close(busydialog)")
refreshProg()
def getProgNextDay():
start = datetime.time(18, 0, 0)
now = datetime.datetime.now().time()
tomorrow = datetime.datetime.today() + datetime.timedelta(days=1)
if now > start:
print 'NextDay ' + str(start) + ' - ' + str(now) + ' - ' + str(tomorrow)
_zattooDB_.updateProgram(tomorrow)
if __addon__.getSetting('dbonstart') == 'true': start()
print "No DB--SERVICE"