feat: auto-rename album directory after in-place apply
After all file operations (rename, tag, cover, playlist), apply now renames the album root directory to match album.json metadata: - input_dir = CD1/CD2 etc.: parent directory is renamed automatically e.g. Kärntner_Doppelsextett/ → Du_Berührst_Mi_20_Jahre_Kärntner_Doppelsextett/ - input_dir = album root: a hint with the mv command is printed instead (avoids renaming an actively used path) - Existing directory with target name: warning, no rename Also: _sanitize_filename() in organizer.py made public (sanitize_filename), used consistently across organizer, playlist and cli modules. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c0e4d2aa85
commit
7554cade50
5 changed files with 148 additions and 20 deletions
|
|
@ -4,36 +4,36 @@ from pathlib import Path
|
|||
|
||||
from musiksammlung.models import Album, Disc, Track
|
||||
from musiksammlung.organizer import (
|
||||
_sanitize_filename,
|
||||
build_mapping,
|
||||
check_disc_counts,
|
||||
discover_audio_files,
|
||||
sanitize_filename,
|
||||
)
|
||||
|
||||
|
||||
class TestSanitizeFilename:
|
||||
"""Tests für _sanitize_filename."""
|
||||
"""Tests für sanitize_filename."""
|
||||
|
||||
def test_replaces_spaces(self) -> None:
|
||||
assert _sanitize_filename("Hello World") == "Hello_World"
|
||||
assert sanitize_filename("Hello World") == "Hello_World"
|
||||
|
||||
def test_replaces_punctuation(self) -> None:
|
||||
assert _sanitize_filename("Song (Live)") == "Song_Live"
|
||||
assert _sanitize_filename("Artist: Name") == "Artist_Name"
|
||||
assert sanitize_filename("Song (Live)") == "Song_Live"
|
||||
assert sanitize_filename("Artist: Name") == "Artist_Name"
|
||||
|
||||
def test_collapses_multiple_underscores(self) -> None:
|
||||
assert _sanitize_filename("A B") == "A_B"
|
||||
assert _sanitize_filename("A--B") == "A_B"
|
||||
assert sanitize_filename("A B") == "A_B"
|
||||
assert sanitize_filename("A--B") == "A_B"
|
||||
|
||||
def test_strips_leading_trailing_underscores(self) -> None:
|
||||
assert _sanitize_filename("_Test_") == "Test"
|
||||
assert sanitize_filename("_Test_") == "Test"
|
||||
|
||||
def test_keeps_umlauts(self) -> None:
|
||||
assert _sanitize_filename("Für Elise") == "Für_Elise"
|
||||
assert _sanitize_filename("Über den Wolken") == "Über_den_Wolken"
|
||||
assert sanitize_filename("Für Elise") == "Für_Elise"
|
||||
assert sanitize_filename("Über den Wolken") == "Über_den_Wolken"
|
||||
|
||||
def test_keeps_digits(self) -> None:
|
||||
assert _sanitize_filename("Track 01") == "Track_01"
|
||||
assert sanitize_filename("Track 01") == "Track_01"
|
||||
|
||||
|
||||
class TestDiscoverAudioFiles:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue