From 6fa19e3495bceb4c11dbb74ec169738ced428144 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 27 Dec 2020 16:24:40 +0100 Subject: [PATCH] Remove some obsolete code for Kodi Krypton --- resources/lib/app/connection.py | 6 ++-- resources/lib/initialsetup.py | 50 ++++++++++--------------------- resources/lib/kodi_db/music.py | 24 +++++++-------- resources/lib/plex_functions.py | 14 +++------ resources/lib/service_entry.py | 2 -- resources/lib/websocket_client.py | 2 -- 6 files changed, 32 insertions(+), 66 deletions(-) diff --git a/resources/lib/app/connection.py b/resources/lib/app/connection.py index 8e70c80a..1a6ae4a9 100644 --- a/resources/lib/app/connection.py +++ b/resources/lib/app/connection.py @@ -67,8 +67,7 @@ class Connection(object): # Shall we verify SSL certificates? "None" will leave SSL enabled # Ignore this setting for Kodi >= 18 as Kodi 18 is much stricter # with checking SSL certs - self.verify_ssl_cert = None if v.KODIVERSION >= 18 or utils.settings('sslverify') == 'true' \ - else False + self.verify_ssl_cert = None # Do we have an ssl certificate for PKC we need to use? self.ssl_cert_path = utils.settings('sslcert') \ if utils.settings('sslcert') != 'None' else None @@ -89,8 +88,7 @@ class Connection(object): self.server_name, self.machine_identifier, self.server) def load_entrypoint(self): - self.verify_ssl_cert = None if v.KODIVERSION >= 18 or utils.settings('sslverify') == 'true' \ - else False + self.verify_ssl_cert = None self.ssl_cert_path = utils.settings('sslcert') \ if utils.settings('sslcert') != 'None' else None self.https = utils.settings('https') == 'true' diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index 86ba59a6..47c5cf70 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -211,8 +211,7 @@ class InitialSetup(object): not set before """ answer = True - chk = PF.check_connection(app.CONN.server, - verifySSL=True if v.KODIVERSION >= 18 else False) + chk = PF.check_connection(app.CONN.server, verifySSL=True) if chk is False: LOG.warn('Could not reach PMS %s', app.CONN.server) answer = False @@ -240,18 +239,13 @@ class InitialSetup(object): """ Checks for server's connectivity. Returns check_connection result """ - if server['local']: - # Deactive SSL verification if the server is local for Kodi 17 - verifySSL = True if v.KODIVERSION >= 18 else False - else: - verifySSL = True if not server['token']: # Plex GDM: we only get the token from plex.tv after # Sign-in to plex.tv server['token'] = utils.settings('plexToken') or None return PF.check_connection(server['baseURL'], token=server['token'], - verifySSL=verifySSL) + verifySSL=True) def pick_pms(self, showDialog=False, inform_of_search=False): """ @@ -550,22 +544,14 @@ class InitialSetup(object): # Display a warning if Kodi puts ALL movies into the queue, basically # breaking playback reporting for PKC - warn = False settings = js.settings_getsettingvalue('videoplayer.autoplaynextitem') - if v.KODIVERSION >= 18: - # Answer for videoplayer.autoplaynextitem: - # [{u'label': u'Music videos', u'value': 0}, - # {u'label': u'TV shows', u'value': 1}, - # {u'label': u'Episodes', u'value': 2}, - # {u'label': u'Movies', u'value': 3}, - # {u'label': u'Uncategorized', u'value': 4}] - if 1 in settings or 2 in settings or 3 in settings: - warn = True - else: - # Kodi Krypton: answer is boolean - if settings: - warn = True - if warn: + # Answer for videoplayer.autoplaynextitem: + # [{u'label': u'Music videos', u'value': 0}, + # {u'label': u'TV shows', u'value': 1}, + # {u'label': u'Episodes', u'value': 2}, + # {u'label': u'Movies', u'value': 3}, + # {u'label': u'Uncategorized', u'value': 4}] + if 1 in settings or 2 in settings or 3 in settings: LOG.warn('Kodi setting videoplayer.autoplaynextitem is: %s', settings) if utils.settings('warned_setting_videoplayer.autoplaynextitem') == 'false': @@ -575,17 +561,13 @@ class InitialSetup(object): # Warning: Kodi setting "Play next video automatically" is # enabled. This could break PKC. Deactivate? if utils.yesno_dialog(utils.lang(29999), utils.lang(30003)): - if v.KODIVERSION >= 18: - for i in (1, 2, 3): - try: - settings.remove(i) - except ValueError: - pass - js.settings_setsettingvalue('videoplayer.autoplaynextitem', - settings) - else: - js.settings_setsettingvalue('videoplayer.autoplaynextitem', - False) + for i in (1, 2, 3): + try: + settings.remove(i) + except ValueError: + pass + js.settings_setsettingvalue('videoplayer.autoplaynextitem', + settings) # Set any video library updates to happen in the background in order to # hide "Compressing database" js.settings_setsettingvalue('videolibrary.backgroundupdate', True) diff --git a/resources/lib/kodi_db/music.py b/resources/lib/kodi_db/music.py index 89f7854b..88c50b45 100644 --- a/resources/lib/kodi_db/music.py +++ b/resources/lib/kodi_db/music.py @@ -48,17 +48,16 @@ class KodiMusicDB(common.KodiDBBase): strRole) VALUES (?, ?) ''', (1, 'Artist')) - if v.KODIVERSION >= 18: - self.cursor.execute('DELETE FROM versiontagscan') - self.cursor.execute(''' - INSERT INTO versiontagscan( - idVersion, - iNeedsScan, - lastscanned) - VALUES (?, ?, ?) - ''', (v.DB_MUSIC_VERSION, - 0, - timing.kodi_now())) + self.cursor.execute('DELETE FROM versiontagscan') + self.cursor.execute(''' + INSERT INTO versiontagscan( + idVersion, + iNeedsScan, + lastscanned) + VALUES (?, ?, ?) + ''', (v.DB_MUSIC_VERSION, + 0, + timing.kodi_now())) @db.catch_operationalerrors def update_path(self, path, kodi_pathid): @@ -487,9 +486,6 @@ class KodiMusicDB(common.KodiDBBase): @db.catch_operationalerrors def remove_album(self, kodi_id): - if v.KODIVERSION < 18: - self.cursor.execute('DELETE FROM albuminfosong WHERE idAlbumInfo = ?', - (kodi_id, )) self.cursor.execute('DELETE FROM album_artist WHERE idAlbum = ?', (kodi_id, )) self.cursor.execute('DELETE FROM album WHERE idAlbum = ?', (kodi_id, )) diff --git a/resources/lib/plex_functions.py b/resources/lib/plex_functions.py index 48400f1b..fbeeb8b7 100644 --- a/resources/lib/plex_functions.py +++ b/resources/lib/plex_functions.py @@ -127,12 +127,6 @@ def check_connection(url, token=None, verifySSL=None): header_options = None if token is not None: header_options = {'X-Plex-Token': token} - if verifySSL is True: - if v.KODIVERSION >= 18: - # Always verify with Kodi >= 18 - verifySSL = True - else: - verifySSL = True if utils.settings('sslverify') == 'true' else False if 'plex.tv' in url: url = 'https://plex.tv/api/home/users' LOG.debug("Checking connection to server %s with verifySSL=%s", @@ -432,7 +426,7 @@ def _poke_pms(pms, queue): xml = DU().downloadUrl('%s/identity' % url, authenticate=False, headerOptions={'X-Plex-Token': pms['token']}, - verifySSL=True if v.KODIVERSION >= 18 else False, + verifySSL=True, timeout=(3.0, 5.0)) try: xml.attrib['machineIdentifier'] @@ -888,7 +882,7 @@ def GetMachineIdentifier(url): """ xml = DU().downloadUrl('%s/identity' % url, authenticate=False, - verifySSL=True if v.KODIVERSION >= 18 else False, + verifySSL=True, timeout=10, reraise=True) try: @@ -1000,7 +994,7 @@ def pms_root(url, token): return DU().downloadUrl( url, authenticate=False, - verifySSL=True if v.KODIVERSION >= 18 else False, + verifySSL=True, headerOptions={'X-Plex-Token': token} if token else None) @@ -1013,7 +1007,7 @@ def get_PMS_settings(url, token): return DU().downloadUrl( '%s/:/prefs' % url, authenticate=False, - verifySSL=True if v.KODIVERSION >= 18 else False, + verifySSL=True, headerOptions={'X-Plex-Token': token} if token else None) diff --git a/resources/lib/service_entry.py b/resources/lib/service_entry.py index 6791aead..e17ac039 100644 --- a/resources/lib/service_entry.py +++ b/resources/lib/service_entry.py @@ -266,8 +266,6 @@ class Service(object): # Save changes to to file self.setup.save_pms_settings(server['baseURL'], server['token']) self.setup.write_pms_to_settings(server) - if not v.KODIVERSION >= 18: - utils.settings('sslverify', value='false') # Wipe Kodi and Plex database as well as playlists and video nodes utils.wipe_database() app.CONN.load() diff --git a/resources/lib/websocket_client.py b/resources/lib/websocket_client.py index f61d9f6f..5ce265e8 100644 --- a/resources/lib/websocket_client.py +++ b/resources/lib/websocket_client.py @@ -165,8 +165,6 @@ class PMS_Websocket(WebSocket): if app.ACCOUNT.pms_token: uri += '?X-Plex-Token=%s' % app.ACCOUNT.pms_token sslopt = {} - if v.KODIVERSION == 17 and utils.settings('sslverify') == "false": - sslopt["cert_reqs"] = CERT_NONE LOG.debug("%s: Uri: %s, sslopt: %s", self.__class__.__name__, uri, sslopt) return uri, sslopt