Fix CDDB parser: only ' / ' splits artist/title, never ' - '
Classical titles like 'Sonate: I. Largo - Allegro' were incorrectly split at the movement-separator dash, producing wrong artist/title pairs. Now only ' / ' (CDDB compilation standard) is treated as artist-title separator; ' - ' is always part of the title. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9e61b01f92
commit
12bf67e977
2 changed files with 39 additions and 21 deletions
|
|
@ -63,31 +63,34 @@ class TestCleanInput:
|
|||
class TestParseCddbLines:
|
||||
"""Tests für _parse_cddb_lines."""
|
||||
|
||||
def test_parse_single_track(self) -> None:
|
||||
lines = ["1: Artist - Title"]
|
||||
def test_parse_single_track_title_only(self) -> None:
|
||||
"""Reguläres Album: Zeile ohne ' / ' → artist leer, gesamter Inhalt = Titel."""
|
||||
lines = ["1: Für Elise"]
|
||||
tracks = _parse_cddb_lines(lines)
|
||||
assert len(tracks) == 1
|
||||
assert tracks[0].track_number == 1
|
||||
assert tracks[0].artist == "Artist"
|
||||
assert tracks[0].title == "Title"
|
||||
assert tracks[0].artist == ""
|
||||
assert tracks[0].title == "Für Elise"
|
||||
|
||||
def test_parse_multiple_tracks(self) -> None:
|
||||
def test_parse_regular_multiple_tracks(self) -> None:
|
||||
"""Mehrere reguläre Tracks werden korrekt geparst."""
|
||||
lines = [
|
||||
"1: Artist One - Title One",
|
||||
"2: Artist Two - Title Two",
|
||||
"3: Artist Three - Title Three",
|
||||
"1: First Title",
|
||||
"2: Second Title",
|
||||
"3: Third Title",
|
||||
]
|
||||
tracks = _parse_cddb_lines(lines)
|
||||
assert len(tracks) == 3
|
||||
assert tracks[2].track_number == 3
|
||||
assert tracks[2].artist == "Artist Three"
|
||||
assert tracks[2].title == "Title Three"
|
||||
assert tracks[2].artist == ""
|
||||
assert tracks[2].title == "Third Title"
|
||||
|
||||
def test_parse_with_spaces_in_title(self) -> None:
|
||||
lines = ["1: Wolfgang Anheisser - Wer recht in Freuden wandern will"]
|
||||
def test_dash_in_title_not_split(self) -> None:
|
||||
"""' - ' in klassischen Titeln wird NICHT als Künstler-Separator behandelt."""
|
||||
lines = ['1: Sonata "Tempest": I. Largo - Allegro']
|
||||
tracks = _parse_cddb_lines(lines)
|
||||
assert tracks[0].artist == "Wolfgang Anheisser"
|
||||
assert tracks[0].title == "Wer recht in Freuden wandern will"
|
||||
assert tracks[0].artist == ""
|
||||
assert tracks[0].title == 'Sonata "Tempest": I. Largo - Allegro'
|
||||
|
||||
def test_ignores_non_matching_lines(self) -> None:
|
||||
lines = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue