From de4d953477b8d0d2e3c8308cf4d569cd1521d95f Mon Sep 17 00:00:00 2001 From: Ji WenCong Date: Sat, 23 May 2026 23:25:15 +0900 Subject: [PATCH] Fixed a special character issue on Windows. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change(s): [1] This commit fixed an issue that the output filename can't be correctly determined on Windows when the title of an audiobook contains any special character. For example, the title '君を守ろうとする猫の話: (小学館)' can't be correctly handled due to the fact that it contains ':' character. To solve this problem, the changes in this commit will replace all special characters with underline character ('_'). Contributor(s): [1] Ji WenCong --- src/snowcrypt/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/snowcrypt/main.py b/src/snowcrypt/main.py index 415b188..fca1e84 100755 --- a/src/snowcrypt/main.py +++ b/src/snowcrypt/main.py @@ -3,6 +3,8 @@ import queue import threading import logging +import sys +import re from os import path from datetime import datetime @@ -60,6 +62,11 @@ def _get_args_for(file) -> list: title = tags.title.replace(' (Unabridged)', '') outfile = title + '.m4a' + # Match Microsoft Windows reserved characters and control characters, replace + # them with underline character ('_'). + if sys.platform == 'win32': + outfile = re.sub(r'[<>:"/\\|?*\x00-\x1f]', '_', outfile) + return [infile, outfile, key, iv]