feat: always embed an album tag (default 'Unknown Album')
Downloads with no album (regular YouTube videos, fan edits, etc) left a blank album, which trips up players like Plexamp. yt_download now appends --parse-metadata "%(album|Unknown Album)s:%(meta_album)s" so the native/resolved album is kept when present, else 'Unknown Album' is embedded. Applies to all download paths (search, playlist, single URL). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -618,6 +618,9 @@ def yt_download(url_or_query: str, target_folder: Optional[str], quality: str, d
|
||||
cmd += ["--parse-metadata", f"{hit.title}:%(title)s"]
|
||||
if hit.year:
|
||||
cmd += ["--parse-metadata", f"{hit.year}:%(release_year)s"]
|
||||
# Always embed an album: the resolved/native album if present, else a
|
||||
# placeholder so players (e.g. Plexamp) don't choke on a blank album.
|
||||
cmd += ["--parse-metadata", "%(album|Unknown Album)s:%(meta_album)s"]
|
||||
cmd.append(url_or_query)
|
||||
|
||||
dest = outtmpl or target_folder
|
||||
|
||||
@@ -102,3 +102,11 @@ def test_yt_download_returns_true_on_zero_exit(monkeypatch):
|
||||
|
||||
def test_yt_download_dry_run_returns_true():
|
||||
assert mf.yt_download("u", "/tmp/x", "best", True) is True
|
||||
|
||||
|
||||
def test_yt_download_always_sets_album_default(monkeypatch):
|
||||
captured = {}
|
||||
monkeypatch.setattr(mf.os, "makedirs", lambda *a, **k: None)
|
||||
monkeypatch.setattr(mf.subprocess, "run", lambda cmd, **k: captured.update(cmd=cmd) or _CP(""))
|
||||
mf.yt_download("u", "/tmp/x", "best", False)
|
||||
assert "%(album|Unknown Album)s:%(meta_album)s" in captured["cmd"]
|
||||
|
||||
Reference in New Issue
Block a user