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