Skip to content

Commit

Permalink
Add client native mode path replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
sundermann committed Oct 5, 2024
1 parent 1637658 commit e4e5fab
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
13 changes: 13 additions & 0 deletions jellyfin_kodi/helper/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
40 changes: 40 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 11 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
<setting label="30536" id="dbSyncScreensaver" type="bool" default="true" />
<setting label="33111" type="lsep" />
<setting label="30511" id="useDirectPaths" type="enum" lvalues="33036|33037" default="1" />
<setting label="33203" id="directPathReplace1" type="text" default="" />
<setting label="33204" id="directPathReplaceWith1" type="folder" source="" default="" />
<setting label="33205" id="directPathReplace2" type="text" default="" />
<setting label="33206" id="directPathReplaceWith2" type="folder" source="" default="" />
<setting label="33207" id="directPathReplace3" type="text" default="" />
<setting label="33208" id="directPathReplaceWith3" type="folder" source="" default="" />
<setting label="33209" id="directPathReplace4" type="text" default="" />
<setting label="33210" id="directPathReplaceWith4" type="folder" source="" default="" />
<setting label="33211" id="directPathReplace5" type="text" default="" />
<setting label="33212" id="directPathReplaceWith5" type="folder" source="" default="" />
<setting label="Custom List" id="customList" type="action" action="RunScript(script.customlist)" />

<setting label="33175" type="lsep" />
<setting label="30515" id="limitIndex" type="slider" default="15" range="1, 1, 100" option="int" />
Expand Down

0 comments on commit e4e5fab

Please sign in to comment.