diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index 4c33a702..377df6a3 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -67,15 +67,15 @@ class DownloadUtils(): certificate must be path to certificate or 'None' """ if verifySSL is None: - verifySSL = settings('sslverify') + verifySSL = state.VERIFY_SSL_CERT if certificate is None: - certificate = settings('sslcert') - log.debug("Verify SSL certificates set to: %s" % verifySSL) - log.debug("SSL client side certificate set to: %s" % certificate) - if verifySSL != 'true': - self.s.verify = False - if certificate != 'None': + certificate = state.SSL_CERT_PATH + # Set the session's parameters + self.s.verify = verifySSL + if certificate: self.s.cert = certificate + log.debug("Verify SSL certificates set to: %s", verifySSL) + log.debug("SSL client side certificate set to: %s", certificate) def startSession(self, reset=False): """ @@ -177,8 +177,9 @@ class DownloadUtils(): headerOptions = self.getHeader(options=headerOptions) else: headerOptions = headerOverride - if settings('sslcert') != 'None': - kwargs['cert'] = settings('sslcert') + kwargs['verify'] = state.VERIFY_SSL_CERT + if state.SSL_CERT_PATH: + kwargs['cert'] = state.SSL_CERT_PATH # Set the variables we were passed (fallback to request session # otherwise - faster) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index f1eb6841..7813568e 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -46,7 +46,9 @@ STATE_SETTINGS = { 'remapSMBphotoOrg': 'remapSMBphotoOrg', 'remapSMBphotoNew': 'remapSMBphotoNew', 'enableMusic': 'ENABLE_MUSIC', - 'enableBackgroundSync': 'BACKGROUND_SYNC' + 'enableBackgroundSync': 'BACKGROUND_SYNC', + 'sslverify': 'VERIFY_SSL_CERT', + 'sslcert': 'SSL_CERT_PATH' } ############################################################################### @@ -113,6 +115,8 @@ class KodiMonitor(Monitor): state.BACKGROUNDSYNC_SAFTYMARGIN = int( settings('backgroundsync_saftyMargin')) state.SYNC_THREAD_NUMBER = int(settings('syncThreadNumber')) + state.SSL_CERT_PATH = settings('sslcert') \ + if settings('sslcert') != 'None' else None # Never set through the user # state.KODI_PLEX_TIME_OFFSET = float(settings('kodiplextimeoffset')) if changed is True: diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index f7df635d..8c6dc8c8 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -50,33 +50,12 @@ 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.user = userclient.UserClient() self.vnodes = videonodes.VideoNodes() self.xbmcplayer = xbmc.Player() - 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.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 = 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 - state.KODI_PLEX_TIME_OFFSET = float(settings('kodiplextimeoffset')) Thread.__init__(self) def showKodiNote(self, message, icon="plex"): diff --git a/resources/lib/state.py b/resources/lib/state.py index 50578541..6ac85f40 100644 --- a/resources/lib/state.py +++ b/resources/lib/state.py @@ -63,6 +63,10 @@ remapSMBmusicNew = None remapSMBphotoOrg = None remapSMBphotoNew = None +# Shall we verify SSL certificates? +VERIFY_SSL_CERT = False +# Do we have an ssl certificate for PKC we need to use? +SSL_CERT_PATH = None # Along with window('plex_authenticated') AUTHENTICATED = False # plex.tv username diff --git a/service.py b/service.py index 04525b5b..72d7fed3 100644 --- a/service.py +++ b/service.py @@ -120,6 +120,25 @@ class Service(): videonodes.VideoNodes().clearProperties() # Init some stuff + state.VERIFY_SSL_CERT = settings('sslverify') == 'true' + state.SSL_CERT_PATH = settings('sslcert') \ + if settings('sslcert') != 'None' else None + state.FULL_SYNC_INTERVALL = int(settings('fullSyncInterval')) * 60 + state.SYNC_THREAD_NUMBER = int(settings('syncThreadNumber')) + state.SYNC_DIALOG = settings('dbSyncIndicator') == 'true' + state.ENABLE_MUSIC = settings('enableMusic') == 'true' + state.BACKGROUND_SYNC = settings( + 'enableBackgroundSync') == 'true' + state.BACKGROUNDSYNC_SAFTYMARGIN = int( + settings('backgroundsync_saftyMargin')) + 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)) + state.KODI_PLEX_TIME_OFFSET = float(settings('kodiplextimeoffset')) + window('plex_minDBVersion', value="1.5.10") set_webserver() self.monitor = Monitor()