From ab467e36f040aeab2017d2cbe9de2f92c8680aed Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 2 Mar 2016 13:29:07 -0600 Subject: [PATCH 1/5] Fix unicode --- resources/lib/userclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index 066f1a6b..ecda0a9c 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -349,7 +349,7 @@ class UserClient(threading.Thread): # If user has password if user['HasPassword'] == True: password = dialog.input( - heading="%s %s" % (lang(33008), username), + heading="%s %s" % (lang(33008), username.decode('utf-8')), option=xbmcgui.ALPHANUM_HIDE_INPUT) # If password dialog is cancelled if not password: From f16b5dfff6423e748320a4f7b6e29dc61d64f1eb Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 2 Mar 2016 14:50:08 -0600 Subject: [PATCH 2/5] Prevent errors during the view creation For grouped folders only. Include the itemtype to make sure we can correctly search the reference under the grouped view. --- resources/lib/librarysync.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index bc2b5b81..85391dc1 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -385,6 +385,7 @@ class LibrarySync(threading.Thread): if view['type'] == "mixed": sorted_views.append(view['name']) sorted_views.append(view['name']) + log("Sorted views: %s" % sorted_views, 1) try: groupedFolders = self.user.userSettings['Configuration']['GroupedFolders'] @@ -399,6 +400,15 @@ class LibrarySync(threading.Thread): current_views = emby_db.getViews() # Set views for supported media type + emby_mediatypes = { + + 'movies': "Movie", + 'tvshows': "Series", + 'musicvideos': "MusicVideo", + 'homevideos': "Video", + 'music': "Audio", + 'photos': "Photo" + } mediatypes = ['movies', 'tvshows', 'musicvideos', 'homevideos', 'music', 'photos'] for mediatype in mediatypes: @@ -416,8 +426,10 @@ class LibrarySync(threading.Thread): # Media folders are grouped into userview url = "{server}/emby/Users/{UserId}/Items?format=json" params = { + 'ParentId': folderid, - 'Limit': 1 + 'Limit': 1, + 'IncludeItemTypes': emby_mediatypes[mediatype] } # Get one item from server using the folderid result = doUtils(url, parameters=params) try: @@ -434,8 +446,13 @@ class LibrarySync(threading.Thread): # Take the userview, and validate the item belong to the view if emby.verifyView(grouped_view['Id'], verifyitem): # Take the name of the userview + log("Found corresponding view: %s %s" + % (grouped_view['Name'], grouped_view['Id']), 1) foldername = grouped_view['Name'] break + else: + # Unable to find a match, add the name to our sorted_view list + sorted_views.append(foldername) # Get current media folders from emby database view = emby_db.getView_byId(folderid) From 405cecfec786d7194a1492cafda4ebc5200c6f53 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 2 Mar 2016 18:23:51 -0600 Subject: [PATCH 3/5] Version bump 2.2.6 --- addon.xml | 2 +- changelog.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index 1b3fb5fb..a64d8de4 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/changelog.txt b/changelog.txt index d8a3d486..200c0696 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +version 2.2.6 +- Fix unicode error +- Fix grouped folders error + version 2.2.5 - Add generate a new device Id option, found in the add-on settings > advanced. - Offer to delete cached thumbnails upon database reset. From 2a107b45fe5369163c20cac6f8b8c7a3cb2007d8 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 2 Mar 2016 18:25:17 -0600 Subject: [PATCH 4/5] Prevent screensaver during sync Initial, repair, manual syncs. --- resources/lib/librarysync.py | 6 ++++++ resources/lib/utils.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) 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() From c02c7ce242d926a2be1b2801743bbd249f416a23 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 2 Mar 2016 18:26:38 -0600 Subject: [PATCH 5/5] Version bump 2.2.7 --- addon.xml | 2 +- changelog.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index a64d8de4..246aea0f 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/changelog.txt b/changelog.txt index 200c0696..03f8f2c7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +version 2.2.7 +- Prevent Kodi screensaver during the initial sync + version 2.2.6 - Fix unicode error - Fix grouped folders error