Enable many setting changes without Kodi restart
This commit is contained in:
parent
261a0aad4c
commit
cb459f2fd5
5 changed files with 48 additions and 28 deletions
|
@ -47,7 +47,9 @@ STATE_SETTINGS = {
|
|||
'remapSMBmusicOrg': state.remapSMBmusicOrg,
|
||||
'remapSMBmusicNew': state.remapSMBmusicNew,
|
||||
'remapSMBphotoOrg': state.remapSMBphotoOrg,
|
||||
'remapSMBphotoNew': state.remapSMBphotoNew
|
||||
'remapSMBphotoNew': state.remapSMBphotoNew,
|
||||
'enableMusic': state.ENABLE_MUSIC,
|
||||
'enableBackgroundSync': state.BACKGROUND_SYNC
|
||||
}
|
||||
###############################################################################
|
||||
|
||||
|
@ -101,6 +103,13 @@ class KodiMonitor(Monitor):
|
|||
log.debug('PKC settings changed: %s is now %s'
|
||||
% (settings_value, new))
|
||||
state_value = new
|
||||
# Special cases, overwrite all internal settings
|
||||
state.FULL_SYNC_INTERVALL = int(settings('fullSyncInterval'))*60
|
||||
state.BACKGROUNDSYNC_SAFTYMARGIN = int(
|
||||
settings('backgroundsync_saftyMargin'))
|
||||
state.SYNC_THREAD_NUMBER = int(settings('syncThreadNumber'))
|
||||
# Never set through the user
|
||||
# state.KODI_PLEX_TIME_OFFSET = float(settings('kodiplextimeoffset'))
|
||||
|
||||
@CatchExceptions(warnuser=False)
|
||||
def onNotification(self, sender, method, data):
|
||||
|
|
|
@ -55,34 +55,33 @@ class LibrarySync(Thread):
|
|||
if settings('FanartTV') == 'true':
|
||||
self.fanartthread = Process_Fanart_Thread(self.fanartqueue)
|
||||
# How long should we wait at least to process new/changed PMS items?
|
||||
self.saftyMargin = int(settings('backgroundsync_saftyMargin'))
|
||||
|
||||
self.fullSyncInterval = int(settings('fullSyncInterval')) * 60
|
||||
|
||||
self.user = userclient.UserClient()
|
||||
self.vnodes = videonodes.VideoNodes()
|
||||
self.xbmcplayer = xbmc.Player()
|
||||
|
||||
self.syncThreadNumber = int(settings('syncThreadNumber'))
|
||||
self.installSyncDone = settings('SyncInstallRunDone') == 'true'
|
||||
|
||||
state.FULL_SYNC_INTERVALL = int(settings('fullSyncInterval')) * 60
|
||||
state.SYNC_THREAD_NUMBER = int(settings('syncThreadNumber'))
|
||||
state.SYNC_DIALOG = settings('dbSyncIndicator') == 'true'
|
||||
self.enableMusic = settings('enableMusic') == "true"
|
||||
self.enableBackgroundSync = settings(
|
||||
'enableBackgroundSync') == "true"
|
||||
state.ENABLE_MUSIC = settings('enableMusic') == 'true'
|
||||
state.BACKGROUND_SYNC = settings(
|
||||
'enableBackgroundSync') == 'true'
|
||||
state.BACKGROUNDSYNC_SAFTYMARGIN = int(
|
||||
settings('backgroundsync_saftyMargin'))
|
||||
|
||||
# Show sync dialog even if user deactivated?
|
||||
self.force_dialog = True
|
||||
# Init for replacing paths
|
||||
state.REPLACE_SMB_PATH = True if settings('replaceSMB') == 'true' \
|
||||
else False
|
||||
state.REMAP_PATH = True if settings('remapSMB') == 'true' else False
|
||||
state.REPLACE_SMB_PATH = settings('replaceSMB') == 'true'
|
||||
state.REMAP_PATH = settings('remapSMB') == 'true'
|
||||
for typus in v.REMAP_TYPE_FROM_PLEXTYPE.values():
|
||||
for arg in ('Org', 'New'):
|
||||
key = 'remapSMB%s%s' % (typus, arg)
|
||||
setattr(state, key, settings(key))
|
||||
# Just in case a time sync goes wrong
|
||||
self.timeoffset = int(settings('kodiplextimeoffset'))
|
||||
window('kodiplextimeoffset', value=str(self.timeoffset))
|
||||
state.KODI_PLEX_TIME_OFFSET = float(settings('kodiplextimeoffset'))
|
||||
Thread.__init__(self)
|
||||
|
||||
def showKodiNote(self, message, icon="plex"):
|
||||
|
@ -206,11 +205,10 @@ class LibrarySync(Thread):
|
|||
return False
|
||||
|
||||
# Calculate time offset Kodi-PMS
|
||||
self.timeoffset = int(koditime) - int(plextime)
|
||||
window('kodiplextimeoffset', value=str(self.timeoffset))
|
||||
settings('kodiplextimeoffset', value=str(self.timeoffset))
|
||||
state.KODI_PLEX_TIME_OFFSET = float(koditime) - float(plextime)
|
||||
settings('kodiplextimeoffset', value=str(state.KODI_PLEX_TIME_OFFSET))
|
||||
log.info("Time offset Koditime - Plextime in seconds: %s"
|
||||
% str(self.timeoffset))
|
||||
% str(state.KODI_PLEX_TIME_OFFSET))
|
||||
return True
|
||||
|
||||
def initializeDBs(self):
|
||||
|
@ -291,7 +289,7 @@ class LibrarySync(Thread):
|
|||
'movies': self.PlexMovies,
|
||||
'tvshows': self.PlexTVShows,
|
||||
}
|
||||
if self.enableMusic:
|
||||
if state.ENABLE_MUSIC:
|
||||
process['music'] = self.PlexMusic
|
||||
|
||||
# Do the processing
|
||||
|
@ -305,7 +303,7 @@ class LibrarySync(Thread):
|
|||
|
||||
# Let kodi update the views in any case, since we're doing a full sync
|
||||
xbmc.executebuiltin('UpdateLibrary(video)')
|
||||
if self.enableMusic:
|
||||
if state.ENABLE_MUSIC:
|
||||
xbmc.executebuiltin('UpdateLibrary(music)')
|
||||
|
||||
window('plex_initialScan', clear=True)
|
||||
|
@ -468,7 +466,7 @@ class LibrarySync(Thread):
|
|||
"""
|
||||
Compare the views to Plex
|
||||
"""
|
||||
if state.DIRECT_PATHS is True and self.enableMusic is True:
|
||||
if state.DIRECT_PATHS is True and state.ENABLE_MUSIC is True:
|
||||
if music.set_excludefromscan_music_folders() is True:
|
||||
log.info('Detected new Music library - restarting now')
|
||||
# 'New Plex music library detected. Sorry, but we need to
|
||||
|
@ -721,7 +719,7 @@ class LibrarySync(Thread):
|
|||
getMetadataQueue.put(updateItem)
|
||||
# Spawn GetMetadata threads for downloading
|
||||
threads = []
|
||||
for i in range(min(self.syncThreadNumber, itemNumber)):
|
||||
for i in range(min(state.SYNC_THREAD_NUMBER, itemNumber)):
|
||||
thread = Threaded_Get_Metadata(getMetadataQueue,
|
||||
processMetadataQueue)
|
||||
thread.setDaemon(True)
|
||||
|
@ -1142,7 +1140,7 @@ class LibrarySync(Thread):
|
|||
break
|
||||
if item['state'] == 9:
|
||||
successful = self.process_deleteditems(item)
|
||||
elif now - item['timestamp'] < self.saftyMargin:
|
||||
elif now - item['timestamp'] < state.BACKGROUNDSYNC_SAFTYMARGIN:
|
||||
# We haven't waited long enough for the PMS to finish
|
||||
# processing the item. Do it later (excepting deletions)
|
||||
continue
|
||||
|
@ -1472,11 +1470,11 @@ class LibrarySync(Thread):
|
|||
thread_stopped = self.thread_stopped
|
||||
thread_suspended = self.thread_suspended
|
||||
installSyncDone = self.installSyncDone
|
||||
enableBackgroundSync = self.enableBackgroundSync
|
||||
background_sync = state.BACKGROUND_SYNC
|
||||
fullSync = self.fullSync
|
||||
processMessage = self.processMessage
|
||||
processItems = self.processItems
|
||||
fullSyncInterval = self.fullSyncInterval
|
||||
FULL_SYNC_INTERVALL = state.FULL_SYNC_INTERVALL
|
||||
lastSync = 0
|
||||
lastTimeSync = 0
|
||||
lastProcessing = 0
|
||||
|
@ -1594,7 +1592,7 @@ class LibrarySync(Thread):
|
|||
now = getUnixTimestamp()
|
||||
# Standard syncs - don't force-show dialogs
|
||||
self.force_dialog = False
|
||||
if (now - lastSync > fullSyncInterval and
|
||||
if (now - lastSync > FULL_SYNC_INTERVALL and
|
||||
not self.xbmcplayer.isPlaying()):
|
||||
lastSync = now
|
||||
log.info('Doing scheduled full library scan')
|
||||
|
@ -1618,7 +1616,7 @@ class LibrarySync(Thread):
|
|||
self.syncPMStime()
|
||||
window('plex_dbScan', clear=True)
|
||||
state.DB_SCAN = False
|
||||
elif enableBackgroundSync:
|
||||
elif background_sync:
|
||||
# Check back whether we should process something
|
||||
# Only do this once every while (otherwise, potentially
|
||||
# many screen refreshes lead to flickering)
|
||||
|
|
|
@ -34,6 +34,19 @@ RUN_LIB_SCAN = None
|
|||
SYNC_DIALOG = True
|
||||
# Have we already checked the Kodi DB on consistency?
|
||||
KODI_DB_CHECKED = False
|
||||
# Is synching of Plex music enabled?
|
||||
ENABLE_MUSIC = False
|
||||
# How often shall we sync?
|
||||
FULL_SYNC_INTERVALL = 0
|
||||
# Background Sync enabled at all?
|
||||
BACKGROUND_SYNC = True
|
||||
# How long shall we wait with synching a new item to make sure Plex got all
|
||||
# metadata?
|
||||
BACKGROUNDSYNC_SAFTYMARGIN = 0
|
||||
# How many threads to download Plex metadata on sync?
|
||||
SYNC_THREAD_NUMBER = 0
|
||||
# What's the time offset between the PMS and Kodi?
|
||||
KODI_PLEX_TIME_OFFSET = 0.0
|
||||
|
||||
# Path remapping mechanism (e.g. smb paths)
|
||||
# Do we replace \\myserver\path to smb://myserver/path?
|
||||
|
|
|
@ -267,7 +267,7 @@ def DateToKodi(stamp):
|
|||
None if an error was encountered
|
||||
"""
|
||||
try:
|
||||
stamp = float(stamp) + float(window('kodiplextimeoffset'))
|
||||
stamp = float(stamp) + state.KODI_PLEX_TIME_OFFSET
|
||||
date_time = localtime(stamp)
|
||||
localdate = strftime('%Y-%m-%d %H:%M:%S', date_time)
|
||||
except:
|
||||
|
|
|
@ -113,7 +113,7 @@ class Service():
|
|||
"pms_token", "plex_token",
|
||||
"pms_server", "plex_machineIdentifier", "plex_servername",
|
||||
"plex_authenticated", "PlexUserImage", "useDirectPaths",
|
||||
"kodiplextimeoffset", "countError", "countUnauthorized",
|
||||
"countError", "countUnauthorized",
|
||||
"plex_restricteduser", "plex_allows_mediaDeletion",
|
||||
"plex_command", "plex_result", "plex_force_transcode_pix"
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue