forked from SIMKL/script.simkl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.py
54 lines (46 loc) · 1.66 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
#!/usr/bin/python
# -*- coding: UTF-8 -*-
'''
NOT LICENSED YET
Creator: David Davó <[email protected]>
'''
import sys, os
import xbmcaddon
import xbmc
from resources.lib import interface, engine
from resources.lib import simklapi as API
__addon__ = xbmcaddon.Addon()
interface.__addon__ = __addon__
autoscrobble = __addon__.getSetting("autoscrobble")
def getstr(strid): return __addon__.getLocalizedString(strid)
try:
compdatefile = os.path.join(__addon__.getAddonInfo("path").decode("utf-8"), "resources", "data", "compdate.txt")
with open(xbmc.translatePath(compdatefile), "r") as f:
__compdate__ = f.read()
except:
__compdate__ = "ERROR: No such file or directory"
if __name__ == "__main__":
xbmc.log("Simkl dir: " + str(xbmc.translatePath("special://home")))
xbmc.log("Simkl | Python Version: " + str(sys.version))
xbmc.log("Simkl | "+ str(sys.argv), level=xbmc.LOGDEBUG)
xbmc.log("Simkl | compdate: {0}".format(__compdate__))
monitor = xbmc.Monitor()
player = engine.Player()
player.addon = __addon__
eng = engine.Engine(API.api, player)
#Remember: if getTime() is more than x% scrobble file
#Testing:
#API.api.login()
if API.api.internet == False:
interface.notify(getstr(32027))
elif not API.api.is_user_logged():
API.api.login() #Add "remind me tomorrow button"
#interface.notify(getstr(32026))
else:
interface.notify(getstr(32025).format(API.api.USERSETTINGS["user"]["name"]))
#__addon__.openSettings()
while not monitor.abortRequested():
if monitor.waitForAbort(90):
break
elif player.isPlaying():
player.onPlayBackStopped()