fix(worker): canonicalize bonus-track filenames past the MB tracklist
A track beyond the MusicBrainz tracklist (a Qobuz bonus track) kept streamrip's raw name (e.g. "13. John Mayer - St. Patrick's Day (Album Version).flac") while the main tracklist got clean "## Title" names. plan_track_names now canonicalizes such extras: strip the leading track-number prefix and a leading "<artist> - ", yielding "13 St. Patrick's Day (Album Version).flac". Requires an explicit delimiter after the number so titles like "99 Luftballons" are left alone; with no tracklist resolved at all the on-disk stem is still kept. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,34 @@
|
||||
from lyra_worker._mutagen import plan_track_names
|
||||
from lyra_worker._mutagen import _clean_extra_title, plan_track_names
|
||||
|
||||
|
||||
def test_clean_extra_title_strips_number_and_artist_prefix():
|
||||
assert _clean_extra_title(
|
||||
"13. John Mayer - St. Patrick's Day (Album Version)", "John Mayer"
|
||||
) == "St. Patrick's Day (Album Version)"
|
||||
|
||||
|
||||
def test_clean_extra_title_strips_number_without_artist_prefix():
|
||||
assert _clean_extra_title("13. St. Patrick's Day", "John Mayer") == "St. Patrick's Day"
|
||||
|
||||
|
||||
def test_clean_extra_title_leaves_plain_title_and_numeric_titles():
|
||||
assert _clean_extra_title("Hidden Track", "John Mayer") == "Hidden Track"
|
||||
# "99 Luftballons" has no delimiter after the number -> not a track-number prefix
|
||||
assert _clean_extra_title("99 Luftballons", "Nena") == "99 Luftballons"
|
||||
|
||||
|
||||
def test_plan_canonicalizes_bonus_track_beyond_tracklist():
|
||||
names = [f"{i:02d} Track{i}.flac" for i in range(1, 13)] + [
|
||||
"13. John Mayer - St. Patrick's Day (Album Version).flac"
|
||||
]
|
||||
tracklist = tuple(f"Track{i}" for i in range(1, 13))
|
||||
plan = plan_track_names(names, tracklist, artist="John Mayer")
|
||||
assert plan[12] == (
|
||||
"13. John Mayer - St. Patrick's Day (Album Version).flac",
|
||||
"13 St. Patrick's Day (Album Version).flac",
|
||||
"St. Patrick's Day (Album Version)",
|
||||
13,
|
||||
)
|
||||
|
||||
|
||||
def test_plan_uses_tracklist_titles_and_numbers():
|
||||
|
||||
Reference in New Issue
Block a user