diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 85391dc1..4ac5cdea 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -229,6 +229,8 @@ class LibrarySync(threading.Thread): music_enabled = utils.settings('enableMusic') == "true" xbmc.executebuiltin('InhibitIdleShutdown(true)') + screensaver = utils.getScreensaver() + utils.setScreensaver(value="") window('emby_dbScan', value="true") # Add sources utils.sourcesXML() @@ -280,6 +282,7 @@ class LibrarySync(threading.Thread): completed = process[itemtype](embycursor, kodicursor, pDialog) if not completed: xbmc.executebuiltin('InhibitIdleShutdown(false)') + utils.setScreensaver(value=screensaver) window('emby_dbScan', clear=True) if pDialog: pDialog.close() @@ -307,6 +310,7 @@ class LibrarySync(threading.Thread): completed = self.music(embycursor, musiccursor, pDialog) if not completed: xbmc.executebuiltin('InhibitIdleShutdown(false)') + utils.setScreensaver(value=screensaver) window('emby_dbScan', clear=True) if pDialog: pDialog.close() @@ -334,6 +338,7 @@ class LibrarySync(threading.Thread): elapsedtotal = datetime.now() - starttotal xbmc.executebuiltin('InhibitIdleShutdown(false)') + utils.setScreensaver(value=screensaver) window('emby_dbScan', clear=True) window('emby_initialScan', clear=True) if forceddialog: @@ -453,6 +458,7 @@ class LibrarySync(threading.Thread): else: # Unable to find a match, add the name to our sorted_view list sorted_views.append(foldername) + log("Couldn't find corresponding grouped view: %s" % sorted_views, 1) # Get current media folders from emby database view = emby_db.getView_byId(folderid) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index b1e14638..9e8c1707 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -4,6 +4,7 @@ import cProfile import inspect +import json import pstats import sqlite3 import os @@ -119,6 +120,40 @@ def getKodiMusicDBPath(): % dbVersion.get(kodibuild, "")).decode('utf-8') return dbPath +def getScreensaver(): + # Get the current screensaver value + query = { + + 'jsonrpc': "2.0", + 'id': 0, + 'method': "Settings.getSettingValue", + 'params': { + + 'setting': "screensaver.mode" + } + } + result = xbmc.executeJSONRPC(json.dumps(query)) + result = json.loads(result) + screensaver = result['result']['value'] + + return screensaver + +def setScreensaver(value): + # Toggle the screensaver + query = { + + 'jsonrpc': "2.0", + 'id': 0, + 'method': "Settings.setSettingValue", + 'params': { + + 'setting': "screensaver.mode", + 'value': value + } + } + result = xbmc.executeJSONRPC(json.dumps(query)) + logMsg("EMBY", "Toggling screensaver: %s %s" % (value, result), 1) + def reset(): dialog = xbmcgui.Dialog()