mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-16 17:30:43 +08:00
在集数统计时增加对 “日期 连接符 第x期” 格式的特殊处理
- 修改前端 buildProgressByTaskNameFromLatestFiles 函数,优先检测"日期 连接符 第x期"格式 - 修改后端 extract_progress_from_latest_file 函数,支持相同的格式检测 - 支持多种日期格式:2025-09-08、2025/09/08、2025.09.08 - 支持多种连接符号:空格、连字符、下划线、点号、斜杠 - 当同时存在日期和"第x期"时,优先使用日期进行集数统计 - 保持向后兼容,不影响现有的纯集数和纯日期格式处理 问题:最近转存文件中的"2025-09-08 - 第128期"等格式被错误地使用第128期而不是日期 解决:增加特殊格式检测,当同时存在日期和"第x期"时优先使用日期,支持各种连接符号
This commit is contained in:
parent
aabc5d9afd
commit
02d8f60709
@ -4426,6 +4426,26 @@
|
|||||||
];
|
];
|
||||||
const parseOne = (txt) => {
|
const parseOne = (txt) => {
|
||||||
if (!txt) return null;
|
if (!txt) return null;
|
||||||
|
|
||||||
|
// 特殊处理:检测"日期 连接符 第x期"格式,优先使用日期
|
||||||
|
// 支持各种连接符号:空格、-、_、.、/等
|
||||||
|
const dateEpisodePatterns = [
|
||||||
|
/(\d{4})-(\d{1,2})-(\d{1,2})\s*[-\s_\.\/]\s*第(\d{1,3})期/, // 2025-09-08 - 第128期, 2025-09-08 第128期, 2025-09-08_第128期, 2025-09-08.第128期
|
||||||
|
/(\d{4})\/(\d{1,2})\/(\d{1,2})\s*[-\s_\.\/]\s*第(\d{1,3})期/, // 2025/09/08 - 第128期, 2025/09/08 第128期, 2025/09/08_第128期, 2025/09/08.第128期
|
||||||
|
/(\d{4})\.(\d{1,2})\.(\d{1,2})\s*[-\s_\.\/]\s*第(\d{1,3})期/, // 2025.09.08 - 第128期, 2025.09.08 第128期, 2025.09.08_第128期, 2025.09.08.第128期
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const pattern of dateEpisodePatterns) {
|
||||||
|
const match = String(txt).match(pattern);
|
||||||
|
if (match) {
|
||||||
|
const y = match[1];
|
||||||
|
const mm = String(match[2]).padStart(2, '0');
|
||||||
|
const dd = String(match[3]).padStart(2, '0');
|
||||||
|
return { episode_number: null, air_date: `${y}-${mm}-${dd}` };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 原有的逻辑:先尝试提取集数信息
|
||||||
for (const re of patterns) {
|
for (const re of patterns) {
|
||||||
const m = String(txt).match(re);
|
const m = String(txt).match(re);
|
||||||
if (m) {
|
if (m) {
|
||||||
@ -4435,6 +4455,8 @@
|
|||||||
return { episode_number: parseInt(m[1]), air_date: null };
|
return { episode_number: parseInt(m[1]), air_date: null };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 最后尝试提取日期信息
|
||||||
for (const re of datePatterns) {
|
for (const re of datePatterns) {
|
||||||
const m = String(txt).match(re);
|
const m = String(txt).match(re);
|
||||||
if (m) {
|
if (m) {
|
||||||
|
|||||||
@ -160,6 +160,26 @@ class TaskExtractor:
|
|||||||
if not latest_file:
|
if not latest_file:
|
||||||
return {'episode_number': None, 'air_date': None, 'progress_type': 'unknown'}
|
return {'episode_number': None, 'air_date': None, 'progress_type': 'unknown'}
|
||||||
|
|
||||||
|
# 特殊处理:检测"日期 连接符 第x期"格式,优先使用日期
|
||||||
|
# 支持各种连接符号:空格、-、_、.、/等
|
||||||
|
date_episode_patterns = [
|
||||||
|
r'(\d{4})-(\d{1,2})-(\d{1,2})\s*[-\s_\.\/]\s*第(\d{1,3})期', # 2025-09-08 - 第128期, 2025-09-08 第128期, 2025-09-08_第128期, 2025-09-08.第128期
|
||||||
|
r'(\d{4})/(\d{1,2})/(\d{1,2})\s*[-\s_\.\/]\s*第(\d{1,3})期', # 2025/09/08 - 第128期, 2025/09/08 第128期, 2025/09/08_第128期, 2025/09/08.第128期
|
||||||
|
r'(\d{4})\.(\d{1,2})\.(\d{1,2})\s*[-\s_\.\/]\s*第(\d{1,3})期', # 2025.09.08 - 第128期, 2025.09.08 第128期, 2025.09.08_第128期, 2025.09.08.第128期
|
||||||
|
]
|
||||||
|
|
||||||
|
for pattern in date_episode_patterns:
|
||||||
|
match = re.search(pattern, latest_file)
|
||||||
|
if match:
|
||||||
|
year, month, day = match.groups()[:3] # 只取前3个组(年月日)
|
||||||
|
date_str = f"{year}-{month.zfill(2)}-{day.zfill(2)}"
|
||||||
|
return {
|
||||||
|
'episode_number': None,
|
||||||
|
'season_number': None,
|
||||||
|
'air_date': date_str,
|
||||||
|
'progress_type': 'date'
|
||||||
|
}
|
||||||
|
|
||||||
# 尝试提取集数信息
|
# 尝试提取集数信息
|
||||||
for pattern in self.episode_patterns:
|
for pattern in self.episode_patterns:
|
||||||
match = re.search(pattern, latest_file)
|
match = re.search(pattern, latest_file)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user