refactor(download): remove ProviderCore/download.py, move sanitize_filename to SYS.utils, replace callers to use API.HTTP.HTTPClient

This commit is contained in:
2026-01-06 01:38:59 -08:00
parent 3b363dd536
commit 41c11d39fd
38 changed files with 2640 additions and 526 deletions

View File

@@ -66,6 +66,24 @@ def sanitize_metadata_value(value: Any) -> str | None:
return value
def sanitize_filename(name: str, *, max_len: int = 150) -> str:
"""Return a filesystem-safe filename derived from *name*.
Replaces characters that are invalid on Windows with underscores and
collapses whitespace. Trims trailing periods and enforces a max length.
"""
text = str(name or "").strip()
if not text:
return "download"
forbidden = set('<>:"/\\|?*')
cleaned = "".join("_" if c in forbidden else c for c in text)
cleaned = " ".join(cleaned.split()).strip().strip(".")
if not cleaned:
cleaned = "download"
return cleaned[:max_len]
def unique_preserve_order(values: Iterable[str]) -> list[str]:
seen: set[str] = set()
ordered: list[str] = []