Compare commits
2 commits
f902e50018
...
984d8acc88
| Author | SHA1 | Date | |
|---|---|---|---|
| 984d8acc88 | |||
| 0c0311b00f |
2 changed files with 13 additions and 7 deletions
|
|
@ -86,7 +86,7 @@ def _scan_to_album(
|
|||
_CD_SUBDIR = re.compile(r"^CD\d+$", re.IGNORECASE)
|
||||
|
||||
|
||||
def _rename_album_dir_inplace(input_dir: Path, album: Album) -> None:
|
||||
def _rename_album_dir_inplace(input_dir: Path, album: Album) -> Path:
|
||||
"""Benennt das Album-Wurzelverzeichnis nach den Metadaten um.
|
||||
|
||||
Muss als allerletzter Schritt aufgerufen werden, nachdem Tags,
|
||||
|
|
@ -97,6 +97,9 @@ def _rename_album_dir_inplace(input_dir: Path, album: Album) -> None:
|
|||
Umbenennung erfolgt automatisch.
|
||||
- Sonst (input_dir ist selbst das Album-Wurzelverzeichnis) → nur Hinweis
|
||||
ausgeben, da ein Umbenennen des aktiven Verzeichnisses vermieden wird.
|
||||
|
||||
Returns:
|
||||
Aktualisierter Pfad von input_dir nach dem Umbenennen.
|
||||
"""
|
||||
abs_input = input_dir.resolve()
|
||||
desired = sanitize_filename(album.folder_name)
|
||||
|
|
@ -105,7 +108,7 @@ def _rename_album_dir_inplace(input_dir: Path, album: Album) -> None:
|
|||
# CD-Unterverzeichnis übergeben → Elternverzeichnis umbenennen
|
||||
album_root = abs_input.parent
|
||||
if album_root.name == desired:
|
||||
return # bereits korrekt
|
||||
return input_dir # bereits korrekt
|
||||
new_path = album_root.parent / desired
|
||||
if new_path.exists():
|
||||
typer.echo(
|
||||
|
|
@ -113,9 +116,10 @@ def _rename_album_dir_inplace(input_dir: Path, album: Album) -> None:
|
|||
"Verzeichnis nicht umbenannt.",
|
||||
err=True,
|
||||
)
|
||||
return
|
||||
return input_dir
|
||||
album_root.rename(new_path)
|
||||
typer.echo(f"Verzeichnis umbenannt: {album_root.name} → {desired}")
|
||||
return new_path / abs_input.name # z.B. .../Golden_Oldies_Vol_11/CD1
|
||||
else:
|
||||
# Album-Wurzelverzeichnis direkt übergeben → nur Hinweis
|
||||
if abs_input.name != desired:
|
||||
|
|
@ -123,6 +127,7 @@ def _rename_album_dir_inplace(input_dir: Path, album: Album) -> None:
|
|||
f"Tipp: Verzeichnis manuell umbenennen:\n"
|
||||
f" mv '{abs_input.name}' '{desired}'"
|
||||
)
|
||||
return input_dir
|
||||
|
||||
|
||||
def _check_disc_counts_or_exit(album: Album, input_dir: Path, album_json: Path) -> None:
|
||||
|
|
@ -300,7 +305,7 @@ def apply(
|
|||
generate_playlist(album, album_dir)
|
||||
|
||||
if in_place:
|
||||
_rename_album_dir_inplace(input_dir, album)
|
||||
album_dir = _rename_album_dir_inplace(input_dir, album)
|
||||
|
||||
typer.echo(f"Fertig! Album liegt in: {album_dir}")
|
||||
|
||||
|
|
|
|||
|
|
@ -207,10 +207,11 @@ def _stream_abcde(
|
|||
stripped_hdr = line.strip()
|
||||
print(f"\n {stripped_hdr}", flush=True)
|
||||
# Album-Name zwischen den Strichen extrahieren (einmalig)
|
||||
# Zeile z.B.: "#1 (Musicbrainz): ---- Artist / Album ----"
|
||||
if not detected_album:
|
||||
inner = re.sub(r"^[-\s]+|[-\s]+$", "", stripped_hdr)
|
||||
if inner:
|
||||
detected_album = inner
|
||||
inner_m = re.search(r"-{2,}\s*(.+?)\s*-{2,}", stripped_hdr)
|
||||
if inner_m:
|
||||
detected_album = inner_m.group(1).strip()
|
||||
continue
|
||||
|
||||
# ── CDDB track lines "1: Artist - Title" or "1: Artist / Title"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue