Fix album.json landing in wrong directory
album.json was written to a separately computed album_root that could differ from the actual disc_dir parent (e.g. when CDDB returned a different album name). Now album.json is always saved in disc_dir.parent where the audio files actually reside. Also adopts CDDB album name when the user accepted the default name. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cf836b4528
commit
de12afa67a
2 changed files with 21 additions and 8 deletions
|
|
@ -616,16 +616,25 @@ def interactive_rip(config: RipperConfig) -> None:
|
|||
|
||||
disc_counter += 1
|
||||
|
||||
# CDDB-Albumname übernehmen, wenn der User nur den Default verwendet hat
|
||||
if cddb_album and album_name == f"Album{album_counter}":
|
||||
# CDDB DTITLE: "Artist / Album" → Album extrahieren
|
||||
if " / " in cddb_album:
|
||||
_, cddb_title = cddb_album.split(" / ", 1)
|
||||
else:
|
||||
cddb_title = cddb_album
|
||||
album_name = cddb_title.strip()
|
||||
|
||||
# album_root = tatsächliches Elternverzeichnis der CD-Ordner
|
||||
album_root = disc_dir.parent
|
||||
|
||||
if mb_album:
|
||||
# MusicBrainz-Daten haben Priorität (inkl. Jahr, kuratierte Titel)
|
||||
album_model = mb_album
|
||||
album_root = config.output_dir / _sanitize_name(mb_album.album or album_name)
|
||||
elif all_discs:
|
||||
artist = all_discs[0].tracks[0].artist or album_name
|
||||
artist = all_discs[0].tracks[0].artist or ""
|
||||
album_model = AlbumModel(artist=artist, album=album_name, discs=all_discs)
|
||||
album_root = config.output_dir / _sanitize_name(album_name)
|
||||
else:
|
||||
album_root = config.output_dir / _sanitize_name(album_name)
|
||||
album_model = None
|
||||
|
||||
if album_model is not None:
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ class TestInteractiveRipBarcode:
|
|||
assert (tmp_path / "Abbey_Road" / "album.json").exists()
|
||||
|
||||
def test_manual_album_name_kept_when_not_default(self, tmp_path: Path) -> None:
|
||||
"""Manuell eingegebener Albumname wird NICHT von MusicBrainz überschrieben."""
|
||||
"""Manuell eingegebener Albumname → album.json liegt im manuellen Verzeichnis."""
|
||||
inputs = [
|
||||
"Mein Album", # manuell eingegebener Name
|
||||
"0602557360561", # EAN
|
||||
|
|
@ -472,6 +472,10 @@ class TestInteractiveRipBarcode:
|
|||
):
|
||||
interactive_rip(config)
|
||||
|
||||
# JSON-Inhalt kommt von MusicBrainz (artist/year), aber das Verzeichnis-Layout
|
||||
# richtet sich nach mb_album.album (da MB-Daten Priorität haben)
|
||||
assert (tmp_path / "Abbey_Road" / "album.json").exists()
|
||||
# album.json liegt im Verzeichnis mit dem manuellen Namen (dort liegen die Dateien),
|
||||
# Inhalt stammt aber aus MusicBrainz
|
||||
json_path = tmp_path / "Mein_Album" / "album.json"
|
||||
assert json_path.exists()
|
||||
import json
|
||||
data = json.loads(json_path.read_text())
|
||||
assert data["artist"] == "The Beatles"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue