forked from RGPaul/script.traktutilities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.py
66 lines (48 loc) · 2.21 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
# -*- coding: utf-8 -*-
"""Run at startup to sync items to trakt or clean the trakt library"""
import xbmc
import xbmcaddon
from utilities import Debug, _
import utilities
import notification_service as ns
import sync_update as su
__author__ = "Ralph-Gordon Paul, Adrian Cowan"
__credits__ = ["Ralph-Gordon Paul", "Adrian Cowan", "Justin Nemeth", "Sean Rudford"]
__license__ = "GPL"
__maintainer__ = "Andrew Etches"
__email__ = "andrew.etches@dur.ac.uk"
__status__ = "Production"
__settings__ = xbmcaddon.Addon( "script.traktr" )
Debug("service: " + __settings__.getAddonInfo("id") + " - version: " + __settings__.getAddonInfo("version"))
# starts update/sync
def autostart():
"""Run when xbmc stars up, runs tv or movie sync and cleans based on user settings"""
if utilities.checkSettings(True):
notification_thread = ns.NotificationService()
notification_thread.start()
autosync_movies = __settings__.getSetting("autosync_movies")
autosync_tv = __settings__.getSetting("autosync_tv")
autosync_cleanmoviecollection = __settings__.getSetting("autosync_cleanmovies")
autosync_cleantvshowcollection = __settings__.getSetting("autosync_cleantv")
try:
if autosync_movies == "true":
utilities.notification(_(200), _(110)) # start sync movies
su.sync_movies(daemon=True)
if autosync_cleanmoviecollection == "true":
su.clean_movies(daemon=True)
if xbmc.abortRequested:
raise SystemExit()
if autosync_tv == "true":
utilities.notification(_(200), _(111)) # start tvshow collection update
su.sync_tv(daemon=True)
if autosync_cleantvshowcollection:
su.clean_tv(daemon=True)
if xbmc.abortRequested:
raise SystemExit()
if autosync_tv == "true" or autosync_movies == "true":
utilities.notification(_(200), _(112)) # update / sync done
except SystemExit:
notification_thread.abort_requested = True
Debug("[Service] Auto sync processes aborted due to shutdown request")
notification_thread.join()
autostart()