From 8f0b9f945504a367ebddcecb8afa773adfcb1a6f Mon Sep 17 00:00:00 2001 From: x1ao4 Date: Tue, 23 Sep 2025 13:21:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20EP=20=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=89=A7=E9=9B=86=E7=BC=96=E5=8F=B7=E7=9A=84=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. **Python版本** (`quark_auto_save.py`) - 更新日期过滤正则表达式,保护 E/EP 格式不被误伤 - 完善日期过滤逻辑,添加对 MM-DD 格式的处理 - 增强分辨率标识保护,防止 4K/4k 等被误识别为日期 2. **JavaScript版本** (`sort_file_by_name.js`) - 同步更新日期过滤正则表达式 - 保持前后端逻辑一致性 --- app/static/js/sort_file_by_name.js | 4 ++-- quark_auto_save.py | 38 ++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/app/static/js/sort_file_by_name.js b/app/static/js/sort_file_by_name.js index 745d211..68c00e0 100644 --- a/app/static/js/sort_file_by_name.js +++ b/app/static/js/sort_file_by_name.js @@ -52,7 +52,7 @@ function sortFileByName(file) { } // YY-MM-DD if (date_value === Infinity) { - match = filename.match(/((?:19|20)?\d{2})[-./\s](\d{1,2})[-./\s](\d{1,2})/); + match = filename.match(/(? 0 else '' - if prev_char in 'Ee': + prev_chars = filename_without_dates[max(0, match.start()-2):match.start()] + if prev_chars.endswith(('E', 'e', 'EP', 'Ep', 'ep')): continue - # 保护 E 格式的集编号,如 E07, E14 等 + # 保护 E/EP 格式的集编号,如 E07, E14, EP08 等 if re.match(r'^\d+$', date_str) and len(date_str) <= 3: - prev_char = filename_without_dates[match.start()-1] if match.start() > 0 else '' - if prev_char in 'Ee': + prev_chars = filename_without_dates[max(0, match.start()-2):match.start()] + if prev_chars.endswith(('E', 'e', 'EP', 'Ep', 'ep')): continue month = None day = None @@ -569,6 +569,24 @@ def extract_episode_number(filename, episode_patterns=None, config_data=None): except ValueError: # 转换失败,保持month和day为None pass + elif len(match.groups()) == 2: + # 处理两个分组的模式(如MM-DD格式) + try: + month = int(match.group(1)) + day = int(match.group(2)) + + # 检查月和日的有效性 + if not (1 <= month <= 12 and 1 <= day <= 31): + # 尝试另一种解释:日-月 + month = int(match.group(2)) + day = int(match.group(1)) + if not (1 <= month <= 12 and 1 <= day <= 31): + # 仍然无效,重置month和day + month = None + day = None + except ValueError: + # 转换失败,保持month和day为None + pass # 如果能确定月日且是有效的日期,则从文件名中删除该日期 if month and day and 1 <= month <= 12 and 1 <= day <= 31: