feat: -x/--exclude to skip folders during --repair/--retag-from-path
Repeatable -x/--exclude NAME skips any artist- or source-level folder whose name matches (case-insensitive) when walking the library, so hand-curated folders like /media/music/Unsorted or .../playlists are left untouched. Threaded through _iter_source_files -> repair_library / retag_library_from_path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -159,6 +159,23 @@ def test_repair_library_missing_root():
|
||||
assert mf.repair_library("/no/such/dir", dry_run=False) == (0, 0)
|
||||
|
||||
|
||||
def test_repair_library_exclude_skips_folders(tmp_path, monkeypatch):
|
||||
root = tmp_path
|
||||
(root / "Daft Punk" / "youtube").mkdir(parents=True)
|
||||
(root / "Daft Punk" / "youtube" / f"A [{YT_ID}].opus").write_text("x")
|
||||
(root / "Unsorted" / "youtube").mkdir(parents=True) # excluded artist folder
|
||||
(root / "Unsorted" / "youtube" / f"B [{YT_ID}].opus").write_text("x")
|
||||
(root / "Ephixa" / "playlists").mkdir(parents=True) # excluded source folder
|
||||
(root / "Ephixa" / "playlists" / f"C [{YT_ID}].opus").write_text("x")
|
||||
|
||||
visited = []
|
||||
monkeypatch.setattr(mf, "repair_file",
|
||||
lambda path, source, dry_run: visited.append(path) or ["x"])
|
||||
scanned, _ = mf.repair_library(str(root), dry_run=False, exclude=["unsorted", "playlists"])
|
||||
assert scanned == 1
|
||||
assert visited and "Daft Punk" in visited[0]
|
||||
|
||||
|
||||
# ---- offline retag-from-path ----
|
||||
def test_title_from_filename():
|
||||
assert mf._title_from_filename(f"Song [{YT_ID}].opus") == "Song"
|
||||
|
||||
Reference in New Issue
Block a user