Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use file browser dialog for local path #951

Merged
merged 3 commits into from
Dec 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions jellyfin_kodi/helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import re
import unicodedata
from uuid import uuid4
from urllib.parse import quote_plus
from urllib.parse import quote_plus, urlparse, urlunparse

from dateutil import tz, parser

Expand Down Expand Up @@ -157,6 +157,7 @@ def dialog(dialog_type, *args, **kwargs):
"select": d.select,
"numeric": d.numeric,
"multi": d.multiselect,
"browse": d.browse,
}
return types[dialog_type](*args, **kwargs)

Expand Down Expand Up @@ -487,6 +488,13 @@ def set_addon_mode():
LOG.info("Add-on playback: %s", settings("useDirectPaths") == "0")


def strip_credentials(url):
oddstr13 marked this conversation as resolved.
Show resolved Hide resolved
parsed = urlparse(url)
netloc = parsed.netloc.split("@")[-1] # Remove credentials
stripped_url = urlunparse(parsed._replace(netloc=netloc))
return stripped_url


def path_replacements():
# UI to display and manage path replacements for native mode
from ..database import get_credentials, save_credentials
Expand All @@ -509,7 +517,9 @@ def path_replacements():
if selected_path == 1:
# Add a new path replacement
remote_path = dialog("input", translate(33206))
local_path = dialog("input", translate(33207))
local_path = strip_credentials(
dialog("browse", type=0, heading=translate(33207), shares="")
)
if remote_path and local_path:
paths[remote_path] = local_path
elif selected_path > 1:
Expand All @@ -520,7 +530,15 @@ def path_replacements():
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)
local_path = strip_credentials(
dialog(
"browse",
type=0,
heading=translate(33207),
shares="",
defaultt=edit_local_path,
)
)
if remote_path and local_path:
paths[remote_path] = local_path

Expand Down
Loading