feat: organized album directory and persistent /music bind-mount
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import re
|
||||
|
||||
from lyra_worker.types import MBTarget
|
||||
|
||||
_ILLEGAL = re.compile(r'[<>:"/\\|?*\x00-\x1f]')
|
||||
|
||||
|
||||
def safe_name(s: str) -> str:
|
||||
"""A filesystem-safe path component (single segment, no separators)."""
|
||||
cleaned = _ILLEGAL.sub("_", s).strip().strip(".").strip()
|
||||
return cleaned or "Unknown"
|
||||
|
||||
|
||||
def album_dir(dest_root: str, target: MBTarget) -> str:
|
||||
"""`{dest_root}/{safe artist}/{safe album}[ (year)]`."""
|
||||
album = safe_name(target.album)
|
||||
if target.year:
|
||||
album = f"{album} ({target.year})"
|
||||
return f"{dest_root}/{safe_name(target.artist)}/{album}"
|
||||
Reference in New Issue
Block a user