Skip to content

Commit fae8807

Browse files
committed
fixes for playlist import
1 parent d5f569a commit fae8807

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/tauon/t_modules/t_main.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6924,8 +6924,8 @@ def read_pls(self, lines: list[str], path: str, followed: bool = False) -> None:
69246924
for id in ids:
69256925
if id in urls:
69266926
radio = RadioStation(
6927-
stream_url=titles[id] if id in titles else urls[id],
6928-
title=os.path.splitext(os.path.basename(path))[0],
6927+
stream_url=urls[id],
6928+
title=titles[id] if id in titles else os.path.splitext(os.path.basename(path))[0],
69296929
#scroll=0, # TODO(Martin): This was here wrong as scrolling is meant to be for RadioPlaylist?
69306930
)
69316931

@@ -6981,16 +6981,22 @@ def parse_xspf(self, path: str) -> tuple[list[int], list[RadioStation], str]:
69816981
if "location" in field.tag and field.text:
69826982
loc = field.text
69836983
loc = str(urllib.parse.unquote(loc))
6984+
parsed_loc = urllib.parse.urlparse(loc)
69846985

6985-
try:
6986-
loc = str( Path.from_uri(loc) )
6987-
except Exception:
6988-
logging.exception("Unknown error getting Path from URI")
6989-
6990-
if not Path(loc).is_absolute():
6991-
loc = str(Path(pl_dir / Path(loc)).resolve())
6986+
# Preserve remote stream URLs; only normalize filesystem paths.
6987+
if parsed_loc.scheme and parsed_loc.scheme != "file":
6988+
pass
69926989
else:
6993-
loc = str( Path(loc).resolve() )
6990+
if parsed_loc.scheme == "file":
6991+
try:
6992+
loc = str(Path.from_uri(loc))
6993+
except Exception:
6994+
logging.exception("Unknown error getting Path from URI")
6995+
6996+
if not Path(loc).is_absolute():
6997+
loc = str(Path(pl_dir / Path(loc)).resolve())
6998+
else:
6999+
loc = str(Path(loc).resolve())
69947000

69957001
b["location"] = loc
69967002
if "creator" in field.tag and field.text:

0 commit comments

Comments
 (0)