From b1f04c85a649e59409715e172e3a484922e3c4b6 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 25 Nov 2018 19:46:34 +0100 Subject: [PATCH] Code cleanup --- resources/lib/app/libsync.py | 7 +++---- resources/lib/entrypoint.py | 11 +++-------- resources/lib/initialsetup.py | 8 ++++---- resources/lib/plex_api.py | 3 +-- resources/lib/plexbmchelper/plexgdm.py | 6 +++--- resources/lib/plexbmchelper/subscribers.py | 2 +- resources/lib/service_entry.py | 11 +++-------- 7 files changed, 18 insertions(+), 30 deletions(-) diff --git a/resources/lib/app/libsync.py b/resources/lib/app/libsync.py index 10e1a0d9..a3542601 100644 --- a/resources/lib/app/libsync.py +++ b/resources/lib/app/libsync.py @@ -24,10 +24,8 @@ class Sync(object): self.db_scan = False def load_settings(self): - # Direct Paths (True) or Addon Paths (False)? Along with - # window('useDirectPaths') - self.direct_paths = True if utils.settings('useDirectPaths') == '1' \ - else False + # Direct Paths (True) or Addon Paths (False)? + self.direct_paths = utils.settings('useDirectPaths') == '1' # Is synching of Plex music enabled? self.enable_music = utils.settings('enableMusic') == 'true' # Path remapping mechanism (e.g. smb paths) @@ -35,6 +33,7 @@ class Sync(object): self.replace_smb_path = utils.settings('replaceSMB') == 'true' # Do we generally remap? self.remap_path = utils.settings('remapSMB') == 'true' + self.force_transcode_pix = utils.settings('force_transcode_pix') == 'true' # Mappings for REMAP_PATH: self.remapSMBmovieOrg = utils.settings('remapSMBmovieOrg') self.remapSMBmovieNew = utils.settings('remapSMBmovieNew') diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 9840e0a5..95699f05 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -510,14 +510,9 @@ def on_deck_episodes(viewid, tagname, limit): xbmcplugin.endOfDirectory(int(argv[1]), False) return # We're using another python instance - need to load some vars - if utils.settings('useDirectPaths') == '1': - app.SYNC.direct_paths = True - app.SYNC.replace_smb_path = utils.settings('replaceSMB') == 'true' - app.SYNC.remap_path = utils.settings('remapSMB') == 'true' - if app.SYNC.remap_path: - initialsetup.set_replace_paths() - # Let's NOT check paths for widgets! - app.SYNC.path_verified = True + app.init() + # Let's NOT check paths for widgets! + app.SYNC.path_verified = True counter = 0 for item in xml: api = API(item) diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index fbd4c090..0bc3bf5d 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -544,7 +544,6 @@ class InitialSetup(object): utils.lang(39081), utils.lang(39082)) == 1: LOG.debug("User opted to use direct paths.") utils.settings('useDirectPaths', value="1") - state.DIRECT_PATHS = True # Are you on a system where you would like to replace paths # \\NAS\mymovie.mkv with smb://NAS/mymovie.mkv? (e.g. Windows) if utils.yesno_dialog(utils.lang(29999), utils.lang(39033)): @@ -596,12 +595,13 @@ class InitialSetup(object): # Open Settings page now? You will need to restart! goto_settings = utils.yesno_dialog(utils.lang(29999), utils.lang(39017)) - # Reload relevant settings - app.CONN.load() - app.ACCOUNT.load() if goto_settings: app.APP.suspend = True executebuiltin( 'Addon.OpenSettings(plugin.video.plexkodiconnect)') elif reboot is True: utils.reboot_kodi() + # Reload relevant settings + app.CONN.load() + app.ACCOUNT.load() + app.SYNC.load() diff --git a/resources/lib/plex_api.py b/resources/lib/plex_api.py index f125a061..e18ad7a1 100644 --- a/resources/lib/plex_api.py +++ b/resources/lib/plex_api.py @@ -215,8 +215,7 @@ class API(object): Will always use addon paths, never direct paths """ extension = self.item[0][0].attrib['key'][self.item[0][0].attrib['key'].rfind('.'):].lower() - if (utils.window('plex_force_transcode_pix') == 'true' or - extension not in v.KODI_SUPPORTED_IMAGES): + if app.SYNC.force_transcode_pix or extension not in v.KODI_SUPPORTED_IMAGES: # Let Plex transcode # max width/height supported by plex image transcoder is 1920x1080 path = app.CONN.server + PF.transcode_image_path( diff --git a/resources/lib/plexbmchelper/plexgdm.py b/resources/lib/plexbmchelper/plexgdm.py index 622a12f1..ff441c83 100644 --- a/resources/lib/plexbmchelper/plexgdm.py +++ b/resources/lib/plexbmchelper/plexgdm.py @@ -192,7 +192,7 @@ class plexgdm: log.info("Server list is empty. Unable to check") return False for server in self.server_list: - if server['uuid'] == utils.window('plex_machineIdentifier'): + if server['uuid'] == app.CONN.machine_identifier: media_server = server['server'] media_port = server['port'] scheme = server['protocol'] @@ -243,9 +243,9 @@ class plexgdm: 'owned': '1', 'role': 'master', 'server': currServerIP, - 'serverName': utils.window('plex_servername'), + 'serverName': app.CONN.server_name, 'updated': int(time.time()), - 'uuid': utils.window('plex_machineIdentifier'), + 'uuid': app.CONN.machine_identifier, 'version': 'irrelevant' }] diff --git a/resources/lib/plexbmchelper/subscribers.py b/resources/lib/plexbmchelper/subscribers.py index 43c966b1..07614cab 100644 --- a/resources/lib/plexbmchelper/subscribers.py +++ b/resources/lib/plexbmchelper/subscribers.py @@ -219,7 +219,7 @@ class SubscriptionMgr(object): 'protocol': self.protocol, 'address': self.server, 'port': self.port, - 'machineIdentifier': utils.window('plex_machineIdentifier'), + 'machineIdentifier': app.CONN.machine_identifier, 'state': status, 'type': ptype, 'itemType': ptype, diff --git a/resources/lib/service_entry.py b/resources/lib/service_entry.py index d2fef4b3..f9df487f 100644 --- a/resources/lib/service_entry.py +++ b/resources/lib/service_entry.py @@ -26,14 +26,9 @@ LOG = logging.getLogger("PLEX.service") ############################################################################### WINDOW_PROPERTIES = ( - "plex_command_processed", "plex_shouldStop", "plex_dbScan", - "plex_customplayqueue", "plex_playbackProps", - "pms_token", "plex_token", "pms_server", "plex_machineIdentifier", - "plex_servername", "plex_authenticated", "PlexUserImage", "useDirectPaths", - "plex_restricteduser", - "plex_allows_mediaDeletion", "plex_command", "plex_result", - "plex_force_transcode_pix" -) + "plex_dbScan", "pms_token", "plex_token", "pms_server", + "plex_authenticated", "plex_restricteduser", "plex_allows_mediaDeletion", + "plex_command", "plex_result") class Service():