Skip to content

Commit 0854eca

Browse files
committed
media: fix non-local playlists query
1 parent 28d1bf3 commit 0854eca

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

library/mediadb/db_media.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def func_sort_key(sort_key):
415415
@strings.output_filter(ignore_pattern)
416416
def fn_key(d):
417417
if sort_key in ("parent", "stem", "ps", "pts"):
418-
path = Path(d["path"])
418+
path = Path(d.get("path") or "")
419419

420420
if sort_key == "parent":
421421
return path.parent
@@ -533,7 +533,7 @@ def get_playlist_media(args, playlist_paths) -> list[dict]:
533533
+ ",".join(f":playlist{i}" for i, _ in enumerate(playlist_paths))
534534
+ "))"
535535
)
536-
playlists_params = {f"playlist{i}": str(Path(p).resolve()) for i, p in enumerate(playlist_paths)}
536+
playlists_params = {f"playlist{i}": p for i, p in enumerate(playlist_paths)}
537537

538538
query = f"""WITH m as (
539539
SELECT

library/playback/play_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def process_playqueue(args) -> None:
403403
processes.no_media_found()
404404

405405
path = " ".join(args.include)
406-
media = db_media.get_playlist_media(args, [path])
406+
media = db_media.get_playlist_media(args, [path if path.startswith("http") else str(Path(path).resolve())])
407407
if not media and os.path.exists(path):
408408
media = db_media.get_dir_media(args, [path])
409409
if not media and os.path.exists(args.include[0]):

library/utils/path_utils.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,18 +399,21 @@ def gen_rel_path(source: str, dest: str, relative_to):
399399

400400
if relative_to:
401401
if str(relative_to).startswith("::") and dest.strip(os.sep) in source:
402-
rel = source.split(dest.strip(os.sep), 1)[0]
403-
rel = Path(rel, dest.strip(os.sep), str(relative_to).lstrip(":").lstrip(os.sep)).resolve()
402+
rel_to = source.split(dest.strip(os.sep), 1)[0]
403+
rel_to = Path(rel_to, dest.strip(os.sep), str(relative_to).lstrip(":").lstrip(os.sep)).resolve()
404404
elif str(relative_to).startswith(":"):
405-
rel = os.path.commonpath([abspath, dest])
406-
rel = Path(rel, str(relative_to).lstrip(":").lstrip(os.sep)).resolve()
405+
rel_to = os.path.commonpath([abspath, dest])
406+
rel_to = Path(rel_to, str(relative_to).lstrip(":").lstrip(os.sep)).resolve()
407407
else:
408-
rel = Path(relative_to).expanduser().resolve()
408+
rel_to = Path(relative_to).expanduser().resolve()
409409

410-
log.debug("rel %s", rel)
410+
if not rel_to:
411+
rel_to = mountpoint(abspath)
412+
413+
log.debug("rel_to %s", rel_to)
411414
try:
412-
relpath = abspath.relative_to(rel)
413-
log.debug("abspath %s relative to %s = %s", abspath, rel, relpath)
415+
relpath = abspath.relative_to(rel_to)
416+
log.debug("abspath %s relative to %s = %s", abspath, rel_to, relpath)
414417
except ValueError:
415418
relpath = relativize(abspath)
416419
log.debug("ValueError using abspath %s", relpath)

0 commit comments

Comments
 (0)