From cea2da2e3ca7c857be030d7384e77ae504f9cbc8 Mon Sep 17 00:00:00 2001 From: mcarlton00 Date: Thu, 14 Nov 2024 07:50:18 -0500 Subject: [PATCH] Clear old path replacement before writing new one + linting --- jellyfin_kodi/entrypoint/default.py | 7 ++++++- jellyfin_kodi/helper/api.py | 1 - jellyfin_kodi/helper/utils.py | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/jellyfin_kodi/entrypoint/default.py b/jellyfin_kodi/entrypoint/default.py index 3bf2574a..144c8109 100644 --- a/jellyfin_kodi/entrypoint/default.py +++ b/jellyfin_kodi/entrypoint/default.py @@ -27,7 +27,12 @@ from ..helper import ( JSONRPC, LazyLogger, ) -from ..helper.utils import JsonDebugPrinter, translate_path, kodi_version, path_replacements +from ..helper.utils import ( + JsonDebugPrinter, + translate_path, + kodi_version, + path_replacements +) from ..jellyfin import Jellyfin ################################################################################################# diff --git a/jellyfin_kodi/helper/api.py b/jellyfin_kodi/helper/api.py index 9916a03c..5ec3736c 100644 --- a/jellyfin_kodi/helper/api.py +++ b/jellyfin_kodi/helper/api.py @@ -32,7 +32,6 @@ class API(object): except Exception as e: LOG.warning("Addon appears to not be configured yet: {}".format(e)) - def get_playcount(self, played, playcount): """Convert Jellyfin played/playcount into the Kodi equivalent. The playcount is tied to the watch status. diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index a5064fb0..4a7857b9 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -493,7 +493,7 @@ def path_replacements(): # Retrieve existing stored paths credentials = get_credentials() - if credentials['Servers']: + if credentials["Servers"]: paths = credentials["Servers"][0].get("paths", {}) else: paths = {} @@ -501,7 +501,7 @@ def path_replacements(): # 0 is Finish, -1 is Cancel while selected_path not in [0, -1]: - replace_paths = [ f'{x} : {paths[x]}' for x in paths.keys() ] + replace_paths = [f"{x} : {paths[x]}" for x in paths.keys()] # Insert a "Finish" entry first, and an "Add" entry second replace_paths.insert(0, translate(33204)) replace_paths.insert(1, translate(33205)) @@ -516,6 +516,8 @@ def path_replacements(): # Edit an existing path replacement edit_remote_path = list(paths.keys())[selected_path - 2] edit_local_path = paths[edit_remote_path] + # Deleting the existing path + del paths[edit_remote_path] # Prepopulate the text box with the existing value remote_path = dialog("input", translate(33206), defaultt=edit_remote_path) local_path = dialog("input", translate(33207), defaultt=edit_local_path)