diff --git a/resources/lib/Entrypoint.py b/resources/lib/Entrypoint.py index 6dc4c094..36c2f926 100644 --- a/resources/lib/Entrypoint.py +++ b/resources/lib/Entrypoint.py @@ -7,7 +7,7 @@ import os, sys import threading import json import urllib - +import time WINDOW = xbmcgui.Window(10000) @@ -21,6 +21,7 @@ from API import API ##### Play items via plugin://plugin.video.emby/ ##### def doPlayback(id): + checkService() url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % id result = DownloadUtils().downloadUrl(url) item = PlaybackUtils().PLAY(result, setup="default") @@ -482,4 +483,31 @@ def doMainListing(): addDirectoryItem("Perform local database reset (full resync)", "plugin://plugin.video.emby/?mode=reset") 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() diff --git a/service.py b/service.py index 7616dbf0..664a354c 100644 --- a/service.py +++ b/service.py @@ -5,6 +5,7 @@ import os import threading import json from datetime import datetime +import time cwd = xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('path') BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( cwd, 'resources', 'lib' ) ) @@ -66,7 +67,8 @@ class Service(): WINDOW = self.WINDOW WINDOW.setProperty("Server_online", "") - + WINDOW.setProperty("Emby_Service_Timestamp", str(int(time.time()))) + ConnectionManager().checkServer() lastProgressUpdate = datetime.today() startupComplete = False @@ -78,7 +80,8 @@ class Service(): lastFile = None while not self.KodiMonitor.abortRequested(): - + WINDOW.setProperty("Emby_Service_Timestamp", str(int(time.time()))) + if self.KodiMonitor.waitForAbort(1): # Abort was requested while waiting. We should exit break