From 66822b6d0a55acdb3f6fd68d28d20a0cc438a368 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Sat, 13 Oct 2018 03:53:22 -0500 Subject: [PATCH] Fix update library Only do the compare when user selects update library, also add a restart service option in the add-on settings > advanced --- .../language/resource.language.en_gb/strings.po | 8 ++++++++ resources/lib/entrypoint/default.py | 6 +++++- resources/lib/entrypoint/service.py | 2 +- resources/lib/full_sync.py | 16 ++++++++++------ resources/lib/library.py | 6 +++--- resources/settings.xml | 1 + 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 4e504d26..e00aba33 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -885,3 +885,11 @@ msgstr "" msgctxt "#33179" msgid "Force transcode" msgstr "" + +msgctxt "#33180" +msgid "Restart Emby for Kodi" +msgstr "" + +msgctxt "#33181" +msgid "Restarting to apply the patch" +msgstr "" diff --git a/resources/lib/entrypoint/default.py b/resources/lib/entrypoint/default.py index 6dd02403..2298cd2f 100644 --- a/resources/lib/entrypoint/default.py +++ b/resources/lib/entrypoint/default.py @@ -87,6 +87,8 @@ class Events(object): browse(params.get('type'), params.get('id'), params.get('folder'), server) elif mode == 'synclib': event('SyncLibrary', {'Id': params.get('id')}) + elif mode == 'updatelib': + event('SyncLibrary', {'Id': params.get('id'), 'Update': True}) elif mode == 'repairlib': event('RepairLibrary', {'Id': params.get('id')}) elif mode == 'removelib': @@ -117,6 +119,8 @@ class Events(object): get_themes() elif mode == 'backup': backup() + elif mode == 'restartservice': + window('emby.restart.bool', True) else: listing() @@ -150,7 +154,7 @@ def listing(): if view_id and node in ('movies', 'tvshows', 'musicvideos', 'music') and view_id in whitelist: - context.append((_(33136), "RunPlugin(plugin://plugin.video.emby/?mode=synclib&id=%s)" % view_id)) + context.append((_(33136), "RunPlugin(plugin://plugin.video.emby/?mode=updatelib&id=%s)" % view_id)) context.append((_(33132), "RunPlugin(plugin://plugin.video.emby/?mode=repairlib&id=%s)" % view_id)) context.append((_(33133), "RunPlugin(plugin://plugin.video.emby/?mode=removelib&id=%s)" % view_id)) diff --git a/resources/lib/entrypoint/service.py b/resources/lib/entrypoint/service.py index 21805587..cc7975a3 100644 --- a/resources/lib/entrypoint/service.py +++ b/resources/lib/entrypoint/service.py @@ -341,7 +341,7 @@ class Service(xbmc.Monitor): if not data.get('Id'): return - self.library_thread.add_library(data['Id']) + self.library_thread.add_library(data['Id'], data.get('Update', False)) xbmc.executebuiltin("Container.Refresh") elif method == 'RepairLibrary': diff --git a/resources/lib/full_sync.py b/resources/lib/full_sync.py index 320d1298..4813cb4c 100644 --- a/resources/lib/full_sync.py +++ b/resources/lib/full_sync.py @@ -29,11 +29,11 @@ class FullSync(object): sync = None - def __init__(self, library, library_id=None): + def __init__(self, library, library_id=None, update=False): self.library = library self.direct_path = settings('useDirectPaths') == "1" - + self.update_library = update self.server = Emby() self.sync = get_sync() @@ -253,7 +253,8 @@ class FullSync(object): message=movie['Name']) obj.movie(movie, library=library) - self.movies_compare(library, obj, embydb) + if self.update_library: + self.movies_compare(library, obj, embydb) def movies_compare(self, library, obj, embydb): @@ -297,7 +298,8 @@ class FullSync(object): dialog.update(percent, message="%s/%s" % (message, episode['Name'][:10])) obj.episode(episode) - self.tvshows_compare(library, obj, embydb) + if self.update_library: + self.tvshows_compare(library, obj, embydb) def tvshows_compare(self, library, obj, embydb): @@ -337,7 +339,8 @@ class FullSync(object): message=mvideo['Name']) obj.musicvideo(mvideo, library=library) - self.musicvideos_compare(library, obj, embydb) + if self.update_library: + self.musicvideos_compare(library, obj, embydb) def musicvideos_compare(self, library, obj, embydb): @@ -386,7 +389,8 @@ class FullSync(object): message="%s/%s/%s" % (message, album['Name'][:7], song['Name'][:7])) obj.song(song) - self.music_compare(library, obj, embydb) + if self.update_library: + self.music_compare(library, obj, embydb) def music_compare(self, library, obj, embydb): diff --git a/resources/lib/library.py b/resources/lib/library.py index 4dce1015..702bf77b 100644 --- a/resources/lib/library.py +++ b/resources/lib/library.py @@ -480,12 +480,12 @@ class Library(threading.Thread): library = libraries[x - 1] selected_libraries.append(library['Id']) - event(modes[mode], {'Id': ','.join([libraries[x - 1]['Id'] for x in selection])}) + event(modes[mode], {'Id': ','.join([libraries[x - 1]['Id'] for x in selection]), 'Update': mode == 'SyncLibrarySelection'}) - def add_library(self, library_id): + def add_library(self, library_id, update=False): try: - FullSync(self, library_id) + FullSync(self, library_id, update=update) except Exception as error: LOG.exception(error) diff --git a/resources/settings.xml b/resources/settings.xml index c3f43eae..6bd42c2b 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -93,6 +93,7 @@ +