Add per-track artist to filename: 09_Titel_-_Kuenstler.flac

- Track model: add optional artist field (None = fall back to album artist)
- organizer: append _-_<artist> to each filename
- tagger: use track.artist over album.artist for the 'artist' tag
- playlist: widen glob pattern to match new _-_<artist> suffix
- tests: update assertions + add test for track-artist override

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-02-18 00:11:07 +01:00
commit 255496bd1b
6 changed files with 41 additions and 18 deletions

View file

@ -167,8 +167,8 @@ class TestBuildMapping:
mapping = build_mapping(album, tmp_path, tmp_path / "output")
targets = list(mapping.values())
assert targets[0].name == "01_Erster_Song.flac"
assert targets[1].name == "02_Zweiter_Song.flac"
assert targets[0].name == "01_Erster_Song_-_TestArtist.flac"
assert targets[1].name == "02_Zweiter_Song_-_TestArtist.flac"
# Single-Disc: kein CD1-Unterordner
assert "CD1" not in str(targets[0])
@ -207,7 +207,28 @@ class TestBuildMapping:
# Source and target are in the same directory
assert src.parent == tmp_path
assert dst.parent == tmp_path
assert dst.name == "01_Song.flac"
assert dst.name == "01_Song_-_Artist.flac"
def test_track_artist_overrides_album_artist(self, tmp_path: Path) -> None:
(tmp_path / "track01.flac").touch()
(tmp_path / "track02.flac").touch()
album = Album(
artist="Various Artists",
album="Sampler",
discs=[
Disc(
disc_number=1,
tracks=[
Track(track_number=1, title="Song A", artist="Artist X"),
Track(track_number=2, title="Song B"), # kein Track-Künstler → Fallback
],
)
],
)
mapping = build_mapping(album, tmp_path, in_place=True)
targets = list(mapping.values())
assert targets[0].name == "01_Song_A_-_Artist_X.flac"
assert targets[1].name == "02_Song_B_-_Various_Artists.flac"
def test_output_dir_structure(self, tmp_path: Path) -> None:
(tmp_path / "track01.flac").touch()