-
Notifications
You must be signed in to change notification settings - Fork 3
/
service.py
28 lines (24 loc) · 855 Bytes
/
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
import datetime
import xbmc
from addon import update_library
from resources.lib.xswift2 import plugin
from resources.lib.video_player import PLAYER
def go_idle(duration):
while not xbmc.Monitor().abortRequested() and duration > 0:
if PLAYER.isPlayingVideo():
PLAYER.currentTime = PLAYER.getTime()
xbmc.sleep(1000)
duration -= 1
def future(seconds):
return datetime.datetime.now() + datetime.timedelta(seconds=seconds)
if __name__ == '__main__':
go_idle(5)
if plugin.get_setting('total_setup_done', bool) == False:
xbmc.executebuiltin('RunPlugin(plugin://plugin.video.openmeta/setup/total)')
plugin.set_setting('total_setup_done', 'true')
next_update = future(0)
while not xbmc.Monitor().abortRequested():
if next_update <= future(0):
next_update = future(8*60*60)
update_library()
go_idle(30*60)