From e45a57aed1c1bb9dc2427c4aefca5587b2d709e4 Mon Sep 17 00:00:00 2001 From: x1ao4 Date: Sun, 13 Jul 2025 23:25:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E6=96=87=E4=BB=B6=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E9=80=BB=E8=BE=91=E6=94=AF=E6=8C=81=E4=B8=8A=E4=B8=AD?= =?UTF-8?q?=E4=B8=8B=E5=90=8E=E7=9A=84=E5=BA=8F=E5=8F=B7=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 支持中文数字序号:上(一)、上(二) 按 1、2 排序 - 支持阿拉伯数字序号:上1、上2 按数字排序 --- app/static/js/sort_file_by_name.js | 36 ++++++++++++++++++++++++++---- quark_auto_save.py | 27 +++++++++++++++++++--- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/app/static/js/sort_file_by_name.js b/app/static/js/sort_file_by_name.js index 21c03c0..e0c0c28 100644 --- a/app/static/js/sort_file_by_name.js +++ b/app/static/js/sort_file_by_name.js @@ -166,10 +166,38 @@ function sortFileByName(file) { } } - // 3. 上中下 - if (/[上][集期话部篇]?|[集期话部篇]上/.test(filename)) segment_value = 1; - else if (/[中][集期话部篇]?|[集期话部篇]中/.test(filename)) segment_value = 2; - else if (/[下][集期话部篇]?|[集期话部篇]下/.test(filename)) segment_value = 3; + // 3. 上中下标记或其他细分 - 第三级排序键 + let segment_base = 0; // 基础值:上=1, 中=2, 下=3 + let sequence_number = 0; // 序号值:用于处理上中下后的数字或中文数字序号 + + if (/[上][集期话部篇]?|[集期话部篇]上/.test(filename)) { + segment_base = 1; + } else if (/[中][集期话部篇]?|[集期话部篇]中/.test(filename)) { + segment_base = 2; + } else if (/[下][集期话部篇]?|[集期话部篇]下/.test(filename)) { + segment_base = 3; + } + + // 当有上中下标记时,进一步提取后续的序号 + if (segment_base > 0) { + // 提取上中下后的中文数字序号,如:上(一)、上(二) + let chinese_seq_match = filename.match(/[上中下][集期话部篇]?[((]([一二三四五六七八九十百千万零两]+)[))]/); + if (chinese_seq_match) { + let arabic_num = chineseToArabic(chinese_seq_match[1]); + if (arabic_num !== null) { + sequence_number = arabic_num; + } + } else { + // 提取上中下后的阿拉伯数字序号,如:上1、上2 + let arabic_seq_match = filename.match(/[上中下][集期话部篇]?(\d+)/); + if (arabic_seq_match) { + sequence_number = parseInt(arabic_seq_match[1]); + } + } + } + + // 组合segment_value:基础值*1000 + 序号值,确保排序正确 + segment_value = segment_base * 1000 + sequence_number; return [date_value, episode_value, segment_value, update_time, pinyin_sort_key]; } diff --git a/quark_auto_save.py b/quark_auto_save.py index 80606a1..bf16896 100644 --- a/quark_auto_save.py +++ b/quark_auto_save.py @@ -227,12 +227,33 @@ def sort_file_by_name(file): episode_value = int(any_num_match.group(1)) # 3. 提取上中下标记或其他细分 - 第三级排序键 + segment_base = 0 # 基础值:上=1, 中=2, 下=3 + sequence_number = 0 # 序号值:用于处理上中下后的数字或中文数字序号 + if re.search(r'上[集期话部篇]?|[集期话部篇]上', filename): - segment_value = 1 + segment_base = 1 elif re.search(r'中[集期话部篇]?|[集期话部篇]中', filename): - segment_value = 2 + segment_base = 2 elif re.search(r'下[集期话部篇]?|[集期话部篇]下', filename): - segment_value = 3 + segment_base = 3 + + # 当有上中下标记时,进一步提取后续的序号 + if segment_base > 0: + # 提取上中下后的中文数字序号,如:上(一)、上(二) + chinese_seq_match = re.search(r'[上中下][集期话部篇]?[((]([一二三四五六七八九十百千万零两]+)[))]', filename) + if chinese_seq_match: + chinese_num = chinese_seq_match.group(1) + arabic_num = chinese_to_arabic(chinese_num) + if arabic_num is not None: + sequence_number = arabic_num + else: + # 提取上中下后的阿拉伯数字序号,如:上1、上2 + arabic_seq_match = re.search(r'[上中下][集期话部篇]?(\d+)', filename) + if arabic_seq_match: + sequence_number = int(arabic_seq_match.group(1)) + + # 组合segment_value:基础值*1000 + 序号值,确保排序正确 + segment_value = segment_base * 1000 + sequence_number # 返回多级排序元组,加入更新时间作为第四级排序键,拼音排序作为第五级排序键 return (date_value, episode_value, segment_value, update_time, pinyin_sort_key)