stuff
This commit is contained in:
+22
-3
@@ -69,12 +69,30 @@ _SOURCE_LABEL_RE = re.compile(
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
# Characters that Windows (and SMB shares) forbid in path components.
|
||||
_WIN_ILLEGAL_RE = re.compile(r'[\\/*?"<>|]')
|
||||
|
||||
|
||||
def _natural_key(name: str) -> list:
|
||||
return [int(p) if p.isdigit() else p.lower()
|
||||
for p in re.split(r"(\d+)", name)]
|
||||
|
||||
|
||||
def _sanitize_dirname(name: str) -> str:
|
||||
"""
|
||||
Makes a string safe to use as a Windows (or SMB) directory name.
|
||||
|
||||
Rules applied:
|
||||
- ": " or ":" surrounded by optional spaces -> " - "
|
||||
("Call of the Night: Paradise Arc" -> "Call of the Night - Paradise Arc")
|
||||
- Remaining Windows-illegal chars (\\ / * ? " < > |) are stripped.
|
||||
- Leading/trailing dots and spaces are removed (Windows restriction).
|
||||
"""
|
||||
name = re.sub(r"\s*:\s*", " - ", name)
|
||||
name = _WIN_ILLEGAL_RE.sub("", name)
|
||||
return name.strip(". ")
|
||||
|
||||
|
||||
_SUWAYOMI_WANTED = {"Title", "Series", "Number", "Summary",
|
||||
"Writer", "Penciller", "Genre", "Web",
|
||||
"Year", "Month", "Day"}
|
||||
@@ -326,8 +344,9 @@ class SuwayomiMover:
|
||||
except Exception as exc:
|
||||
print(f" [warn] metadata fetch failed: {exc}")
|
||||
|
||||
# Destination folder uses the MangaBaka canonical title.
|
||||
dest_series = self._dst / mangabaka_title
|
||||
# Destination folder uses the MangaBaka canonical title, sanitized for
|
||||
# Windows / SMB paths (no colons, illegal chars, leading/trailing dots).
|
||||
dest_series = self._dst / _sanitize_dirname(mangabaka_title)
|
||||
dest_series.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
chapter_results: list[dict] = []
|
||||
@@ -403,7 +422,7 @@ if __name__ == "__main__":
|
||||
)
|
||||
|
||||
# Process a single series
|
||||
result = mover.process_series("Yofukashi no Uta")
|
||||
result = mover.process_series("Yofukashi no Uta_ Rakuen-hen")
|
||||
ok = sum(1 for c in result["chapters"] if c["ok"])
|
||||
failed = sum(1 for c in result["chapters"] if not c["ok"])
|
||||
print(f"\nDone: {ok} ok, {failed} failed")
|
||||
|
||||
Reference in New Issue
Block a user