Tagger- und CLI-Tests; Bugfix embed_cover für MP3 ohne ID3-Header
- tests/test_tagger.py: 20 Tests für tag_file, tag_album, _scale_cover_for_embed, embed_cover (FLAC + MP3), embed_album_cover - tests/test_cli.py: 14 Tests für apply (in-place, disc-mismatch, dry-run, playlist, multi-disc), check und scan (via Mock) - tagger.py: embed_cover für MP3 fängt ID3NoHeaderError ab und erstellt einen neuen ID3-Tag wenn keiner vorhanden ist Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
70c096cde4
commit
cfc2a2018e
3 changed files with 548 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ from pathlib import Path
|
|||
|
||||
from mutagen import File as MutagenFile
|
||||
from mutagen.flac import FLAC, Picture
|
||||
from mutagen.id3 import APIC, ID3
|
||||
from mutagen.id3 import APIC, ID3, ID3NoHeaderError
|
||||
from PIL import Image
|
||||
|
||||
from musiksammlung.models import Album, Disc, Track
|
||||
|
|
@ -114,7 +114,10 @@ def embed_cover(audio_path: Path, cover_path: Path) -> None:
|
|||
audio.save()
|
||||
|
||||
elif suffix == ".mp3":
|
||||
audio = ID3(str(audio_path))
|
||||
try:
|
||||
audio = ID3(str(audio_path))
|
||||
except ID3NoHeaderError:
|
||||
audio = ID3()
|
||||
audio.add(APIC(
|
||||
encoding=3,
|
||||
mime=mime,
|
||||
|
|
@ -122,7 +125,7 @@ def embed_cover(audio_path: Path, cover_path: Path) -> None:
|
|||
desc="Front cover",
|
||||
data=cover_data,
|
||||
))
|
||||
audio.save()
|
||||
audio.save(str(audio_path))
|
||||
|
||||
else:
|
||||
logger.debug("Cover-Embedding für %s nicht unterstützt", suffix)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue