From 8b77c14bdb0d9ad99578249c8f40dfefbd172a94 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Thu, 3 Oct 2024 02:39:57 +0200 Subject: [PATCH] Add client native mode path replacement --- jellyfin_kodi/helper/api.py | 13 ++++++ .../resource.language.en_gb/strings.po | 40 +++++++++++++++++++ resources/settings.xml | 10 +++++ 3 files changed, 63 insertions(+) diff --git a/jellyfin_kodi/helper/api.py b/jellyfin_kodi/helper/api.py index 0174c3edb..07c35de9a 100644 --- a/jellyfin_kodi/helper/api.py +++ b/jellyfin_kodi/helper/api.py @@ -198,6 +198,14 @@ def get_mpaa(self, rating=None): return mpaa + def get_native_path_mappings(self): + return { + replace: replace_with + for i in range(1, 6) + if (replace := settings(f"directPathReplace{i}")) + and (replace_with := settings(f"directPathReplaceWith{i}")) + } + def get_file_path(self, path=None): if path is None: @@ -206,6 +214,11 @@ def get_file_path(self, path=None): if not path: return "" + native_mappings = self.get_native_path_mappings() + for replace, replace_with in native_mappings.items(): + if path.startswith(replace): + path = path.replace(replace, replace_with, 1) + if path.startswith("\\\\"): path = ( path.replace("\\\\", "smb://", 1) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index d44a37b1e..f54fcf1f6 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -996,3 +996,43 @@ msgstr "Max artwork resolution" msgctxt "#33202" msgid "Transcode H265/HEVC RExt" msgstr "Transcode H265/HEVC RExt" + +msgctxt "#33203" +msgid "Native path replace 1" +msgstr "Native path replace 1" + +msgctxt "#33204" +msgid "Native path replace with 1" +msgstr "Native path replace with 1" + +msgctxt "#33205" +msgid "Native path replace 2" +msgstr "Native path replace 2" + +msgctxt "#33206" +msgid "Native path replace with 2" +msgstr "Native path replace with 2" + +msgctxt "#33207" +msgid "Native path replace 3" +msgstr "Native path replace 3" + +msgctxt "#33208" +msgid "Native path replace with 3" +msgstr "Native path replace with 3" + +msgctxt "#33209" +msgid "Native path replace 4" +msgstr "Native path replace 4" + +msgctxt "#33210" +msgid "Native path replace with 4" +msgstr "Native path replace with 4" + +msgctxt "#33211" +msgid "Native path replace 5" +msgstr "Native path replace 5" + +msgctxt "#33212" +msgid "Native path replace with 5" +msgstr "Native path replace with 5" diff --git a/resources/settings.xml b/resources/settings.xml index 91bc5f83e..8c94122e4 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -24,6 +24,16 @@ + + + + + + + + + +