Files
Lyra/worker/lyra_worker/library.py
T
Jonathan 2812695465 feat: organized album directory and persistent /music bind-mount
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 23:43:15 +02:00

20 lines
580 B
Python

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}"