mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-13 21:56:11 +00:00
Moving the watchdog to service.py
This commit is contained in:
parent
e685c99b5a
commit
0a948d59f6
2 changed files with 34 additions and 33 deletions
|
@ -21,7 +21,6 @@ from API import API
|
||||||
|
|
||||||
##### Play items via plugin://plugin.video.emby/ #####
|
##### Play items via plugin://plugin.video.emby/ #####
|
||||||
def doPlayback(id):
|
def doPlayback(id):
|
||||||
checkService()
|
|
||||||
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % id
|
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % id
|
||||||
result = DownloadUtils().downloadUrl(url)
|
result = DownloadUtils().downloadUrl(url)
|
||||||
item = PlaybackUtils().PLAY(result, setup="default")
|
item = PlaybackUtils().PLAY(result, setup="default")
|
||||||
|
@ -483,31 +482,3 @@ def doMainListing():
|
||||||
addDirectoryItem("Perform local database reset (full resync)", "plugin://plugin.video.emby/?mode=reset")
|
addDirectoryItem("Perform local database reset (full resync)", "plugin://plugin.video.emby/?mode=reset")
|
||||||
|
|
||||||
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||||
|
|
||||||
def checkService():
|
|
||||||
|
|
||||||
timeStamp = xbmcgui.Window(10000).getProperty("Emby_Service_Timestamp")
|
|
||||||
loops = 0
|
|
||||||
monitor = xbmc.Monitor()
|
|
||||||
while(timeStamp == ""):
|
|
||||||
timeStamp = xbmcgui.Window(10000).getProperty("Emby_Service_Timestamp")
|
|
||||||
loops = loops + 1
|
|
||||||
if(loops == 5):
|
|
||||||
xbmc.log("Emby Service Not Running, no time stamp, exiting")
|
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
|
||||||
language = addon.getLocalizedString
|
|
||||||
xbmcgui.Dialog().ok(language(30135), language(30136), language(30137))
|
|
||||||
sys.exit()
|
|
||||||
if monitor.waitForAbort(1):
|
|
||||||
# Abort was requested while waiting. We should exit
|
|
||||||
return
|
|
||||||
|
|
||||||
xbmc.log("Emby Service Timestamp: " + timeStamp)
|
|
||||||
xbmc.log("Emby Current Timestamp: " + str(int(time.time())))
|
|
||||||
|
|
||||||
if((int(timeStamp) + 30) < int(time.time())):
|
|
||||||
xbmc.log("Emby Service Not Running, time stamp to old, exiting")
|
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
|
||||||
language = addon.getLocalizedString
|
|
||||||
xbmcgui.Dialog().ok(language(30135), language(30136), language(30137))
|
|
||||||
sys.exit()
|
|
||||||
|
|
36
service.py
36
service.py
|
@ -31,6 +31,7 @@ class Service():
|
||||||
newUserClient = None
|
newUserClient = None
|
||||||
|
|
||||||
clientInfo = ClientInformation()
|
clientInfo = ClientInformation()
|
||||||
|
KodiMonitor = KodiMonitor.Kodi_Monitor()
|
||||||
addonName = clientInfo.getAddonName()
|
addonName = clientInfo.getAddonName()
|
||||||
WINDOW = xbmcgui.Window(10000)
|
WINDOW = xbmcgui.Window(10000)
|
||||||
|
|
||||||
|
@ -38,7 +39,6 @@ class Service():
|
||||||
server_online = True
|
server_online = True
|
||||||
|
|
||||||
def __init__(self, *args ):
|
def __init__(self, *args ):
|
||||||
self.KodiMonitor = KodiMonitor.Kodi_Monitor()
|
|
||||||
addonName = self.addonName
|
addonName = self.addonName
|
||||||
|
|
||||||
self.logMsg("Starting Monitor", 0)
|
self.logMsg("Starting Monitor", 0)
|
||||||
|
@ -138,13 +138,12 @@ class Service():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
WINDOW.setProperty("Emby_Service_Timestamp", str(int(time.time())))
|
|
||||||
#full sync
|
#full sync
|
||||||
if (startupComplete == False):
|
if (startupComplete == False):
|
||||||
self.logMsg("Doing_Db_Sync: syncDatabase (Started)")
|
self.logMsg("Doing_Db_Sync: syncDatabase (Started)")
|
||||||
libSync = librarySync.FullLibrarySync()
|
libSync = librarySync.FullLibrarySync()
|
||||||
self.logMsg("Doing_Db_Sync: syncDatabase (Finished) " + str(libSync))
|
self.logMsg("Doing_Db_Sync: syncDatabase (Finished) " + str(libSync))
|
||||||
|
WINDOW.setProperty("Emby_Service_Timestamp", str(int(time.time())))
|
||||||
if (libSync):
|
if (libSync):
|
||||||
startupComplete = True
|
startupComplete = True
|
||||||
else:
|
else:
|
||||||
|
@ -210,6 +209,8 @@ class Service():
|
||||||
# Abort was requested while waiting.
|
# Abort was requested while waiting.
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.checkService()
|
||||||
|
|
||||||
# If user reset library database.
|
# If user reset library database.
|
||||||
if WINDOW.getProperty("SyncInstallRunDone") == "false":
|
if WINDOW.getProperty("SyncInstallRunDone") == "false":
|
||||||
addon = xbmcaddon.Addon('plugin.video.emby')
|
addon = xbmcaddon.Addon('plugin.video.emby')
|
||||||
|
@ -223,5 +224,34 @@ class Service():
|
||||||
|
|
||||||
self.logMsg("======== STOP %s ========" % self.addonName, 0)
|
self.logMsg("======== STOP %s ========" % self.addonName, 0)
|
||||||
|
|
||||||
|
def checkService(self):
|
||||||
|
|
||||||
|
WINDOW = self.WINDOW
|
||||||
|
timeStamp = WINDOW.getProperty("Emby_Service_Timestamp")
|
||||||
|
loops = 0
|
||||||
|
|
||||||
|
while(timeStamp == ""):
|
||||||
|
timeStamp = WINDOW.getProperty("Emby_Service_Timestamp")
|
||||||
|
loops = loops + 1
|
||||||
|
if(loops == 5):
|
||||||
|
self.logMsg("Emby Service Not Running, no time stamp, exiting.", 0)
|
||||||
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
|
language = addon.getLocalizedString
|
||||||
|
xbmcgui.Dialog().ok(language(30135), language(30136), language(30137))
|
||||||
|
sys.exit()
|
||||||
|
if self.KodiMonitor.waitForAbort(1):
|
||||||
|
# Abort was requested while waiting. We should exit
|
||||||
|
return
|
||||||
|
|
||||||
|
self.logMsg("Emby Service Timestamp: " + timeStamp, 2)
|
||||||
|
self.logMsg("Emby Current Timestamp: " + str(int(time.time())), 2)
|
||||||
|
|
||||||
|
if((int(timeStamp) + 30) < int(time.time())):
|
||||||
|
self.logMsg("Emby Service Not Running, time stamp to old, exiting.", 0)
|
||||||
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
|
language = addon.getLocalizedString
|
||||||
|
xbmcgui.Dialog().ok(language(30135), language(30136), language(30137))
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
#start the service
|
#start the service
|
||||||
Service().ServiceEntryPoint()
|
Service().ServiceEntryPoint()
|
||||||
|
|
Loading…
Reference in a new issue