From 743d8dbb2f5f0408672b2df338645860d7bd4da5 Mon Sep 17 00:00:00 2001 From: croneter Date: Mon, 21 Aug 2017 07:42:11 +0200 Subject: [PATCH] Move sync indication setting to state.py --- resources/lib/kodimonitor.py | 49 +++++++++++++++++++++++------------- resources/lib/librarysync.py | 6 ++--- resources/lib/state.py | 5 ++++ 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 79574057..3c60a944 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -20,6 +20,26 @@ import state log = logging.getLogger("PLEX."+__name__) +# settings: window-variable +WINDOW_SETTINGS = { + 'logLevel': 'plex_logLevel', + 'enableContext': 'plex_context', + 'plex_restricteduser': 'plex_restricteduser', + 'remapSMB': 'remapSMB', + 'replaceSMB': 'replaceSMB', + 'force_transcode_pix': 'plex_force_transcode_pix', + 'fetch_pms_item_number': 'fetch_pms_item_number' +} +# Path replacement +for typus in REMAP_TYPE_FROM_PLEXTYPE.values(): + for arg in ('Org', 'New'): + key = 'remapSMB%s%s' % (typus, arg) + WINDOW_SETTINGS[key] = key + +# settings: state-variable (state.py) +STATE_SETTINGS = { + 'dbSyncIndicator': state.SYNC_DIALOG +} ############################################################################### @@ -52,24 +72,8 @@ class KodiMonitor(Monitor): # path to all media files state.STOP_SYNC = False state.PATH_VERIFIED = False - # settings: window-variable - items = { - 'logLevel': 'plex_logLevel', - 'enableContext': 'plex_context', - 'plex_restricteduser': 'plex_restricteduser', - 'dbSyncIndicator': 'dbSyncIndicator', - 'remapSMB': 'remapSMB', - 'replaceSMB': 'replaceSMB', - 'force_transcode_pix': 'plex_force_transcode_pix', - 'fetch_pms_item_number': 'fetch_pms_item_number' - } - # Path replacement - for typus in REMAP_TYPE_FROM_PLEXTYPE.values(): - for arg in ('Org', 'New'): - key = 'remapSMB%s%s' % (typus, arg) - items[key] = key # Reset the window variables from the settings variables - for settings_value, window_value in items.iteritems(): + for settings_value, window_value in WINDOW_SETTINGS.iteritems(): if window(window_value) != settings(settings_value): log.debug('PKC settings changed: %s is now %s' % (settings_value, settings(settings_value))) @@ -77,6 +81,17 @@ class KodiMonitor(Monitor): if settings_value == 'fetch_pms_item_number': log.info('Requesting playlist/nodes refresh') window('plex_runLibScan', value="views") + # Reset the state variables in state.py + for settings_value, state_value in STATE_SETTINGS.iteritems(): + new = settings(settings_value) + if new == 'true': + new = True + elif new == 'false': + new = False + if state_value != new: + log.debug('PKC settings changed: %s is now %s' + % (settings_value, new)) + state_value = new @CatchExceptions(warnuser=False) def onNotification(self, sender, method, data): diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index c60a866c..128a495a 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -65,7 +65,7 @@ class LibrarySync(Thread): self.syncThreadNumber = int(settings('syncThreadNumber')) self.installSyncDone = settings('SyncInstallRunDone') == 'true' - window('dbSyncIndicator', value=settings('dbSyncIndicator')) + state.SYNC_DIALOG = settings('dbSyncIndicator') == 'true' self.enableMusic = settings('enableMusic') == "true" self.enableBackgroundSync = settings( 'enableBackgroundSync') == "true" @@ -95,7 +95,7 @@ class LibrarySync(Thread): if self.xbmcplayer.isPlaying(): # Don't show any dialog if media is playing return - if window('dbSyncIndicator') != 'true': + if state.SYNC_DIALOG is not True: if not forced: return if icon == "plex": @@ -735,7 +735,7 @@ class LibrarySync(Thread): thread.start() threads.append(thread) # Start one thread to show sync progress ONLY for new PMS items - if self.new_items_only is True and window('dbSyncIndicator') == 'true': + if self.new_items_only is True and state.SYNC_DIALOG is True: thread = sync_info.Threaded_Show_Sync_Info(itemNumber, itemType) thread.setDaemon(True) thread.start() diff --git a/resources/lib/state.py b/resources/lib/state.py index ecae0964..91c9d913 100644 --- a/resources/lib/state.py +++ b/resources/lib/state.py @@ -27,6 +27,11 @@ DIRECT_PATHS = False # Shall we replace custom user ratings with the number of versions available? INDICATE_MEDIA_VERSIONS = False +# Stemming from the PKC settings.xml +# Shall we show Kodi dialogs when synching? +SYNC_DIALOG = True + + # Along with window('plex_authenticated') AUTHENTICATED = False # plex.tv username