From f2aa78fa48556b5113cdd6dea8d4f073d5cf352f Mon Sep 17 00:00:00 2001 From: projectdx Date: Tue, 6 Jan 2026 23:36:11 +0900 Subject: [PATCH] Fix: Improve filename sanitization to prevent Windows 8.3 short names on Synology --- info.yaml | 2 +- lib/util.py | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/info.yaml b/info.yaml index 25e0324..c0373ba 100644 --- a/info.yaml +++ b/info.yaml @@ -1,5 +1,5 @@ title: "애니 다운로더" -version: "0.5.39" +version: "0.5.40" package_name: "anime_downloader" developer: "projectdx" description: "anime downloader" diff --git a/lib/util.py b/lib/util.py index 410cb0f..76e1954 100644 --- a/lib/util.py +++ b/lib/util.py @@ -58,11 +58,21 @@ class Util(object): @staticmethod def change_text_for_use_filename(text): - # text = text.replace('/', '') - # 2021-07-31 X:X - # text = text.replace(':', ' ') - text = re.sub('[\\/:*?\"<>|]', ' ', text).strip() - text = re.sub("\s{2,}", ' ', text) + # 1. Remove/replace Windows-forbidden characters + text = re.sub('[\\/:*?"<>|]', ' ', text) + + # 2. Remove consecutive dots (.. → .) + text = re.sub(r'\.{2,}', '.', text) + + # 3. Remove leading/trailing dots and spaces + text = text.strip('. ') + + # 4. Collapse multiple spaces to single space + text = re.sub(r'\s{2,}', ' ', text) + + # 5. Remove any remaining trailing dots (after space collapse) + text = text.rstrip('.') + return text @staticmethod