fix(parser): 支持 Exx 集号写法,修复 E01/E02 全部解析成 01 的问题
- 苍兰诀这类命名 Love.Between.Fairy.and.Devil.2022.E01.V2… 没有 SxxEyy, 旧的 TARGET_EP 会先命中靠左的年份 2022,两个分组都为空 → 全部退化成 01, 触发「同剧集重复集号」安全拦截 - 重写 _episode_of:SxxEyy → EPx/Exx → 第x集/话/期 → 裸数字兜底 - 裸数字兜底排除:年份 19xx/20xx、分辨率/编码(720/1080/265…)、 AAC.2.0 / DDP5.1 这类声道写法,避免把 05.1080p 的 .1 误判成声道 - 实测:苍兰诀 E01~E07 正确映射为 S01E01~S01E07
This commit is contained in:
@@ -97,18 +97,40 @@ class ParserService:
|
||||
|
||||
@staticmethod
|
||||
def _episode_of(stem: str) -> str:
|
||||
"""取集号:优先 SxxEyy,其次 第x集/EPx,最后兜底 01。
|
||||
"""取集号,按可靠性依次尝试:
|
||||
|
||||
不能直接用 TARGET_EP 的第一个分组——它会先命中裸数字(比如年份 2026)。
|
||||
1. SxxEyy —— 标准写法
|
||||
2. EPxx / Exx —— 很多国漫/网剧用 Love.Between.Fairy.and.Devil.2022.E01
|
||||
3. 第x集/话/期 —— 中文写法
|
||||
4. 裸数字兜底 —— 排除年份(19xx/20xx)、分辨率/编码(720/1080/265…)、
|
||||
以及 AAC.2.0 / DDP5.1 这类声道写法
|
||||
|
||||
不能直接用 TARGET_EP 的第一个分组:它会先命中靠左的年份。
|
||||
"""
|
||||
sxe = re.search(r"S(\d{1,2})E(\d{1,4})", stem, re.I)
|
||||
if sxe:
|
||||
return sxe.group(2).zfill(2)
|
||||
match = RegexPatterns.TARGET_EP.search(stem)
|
||||
if match:
|
||||
value = match.group(1) or match.group(2)
|
||||
if value:
|
||||
return value.zfill(2)
|
||||
|
||||
epx = re.search(r"(?<![a-zA-Z])(?:EP|E)[\s._-]?(\d{1,4})(?!\d)", stem, re.I)
|
||||
if epx:
|
||||
return epx.group(1).zfill(2)
|
||||
|
||||
cn = re.search(r"第\s*(\d{1,4})\s*[集话期]", stem)
|
||||
if cn:
|
||||
return cn.group(1).zfill(2)
|
||||
|
||||
for match in re.finditer(r"(?<![a-zA-Z0-9])(\d{1,4})(?![a-zA-Z0-9])", stem):
|
||||
value = match.group(1)
|
||||
number = int(value)
|
||||
if len(value) == 4 and value[:2] in ("19", "20"): # 年份
|
||||
continue
|
||||
if value in {"480", "576", "720", "1080", "2160", "4320", "264", "265"}:
|
||||
continue
|
||||
if not 1 <= number <= 999:
|
||||
continue
|
||||
if re.match(r"\.[01](?![0-9])", stem[match.end():]): # 2.0 / 5.1 声道
|
||||
continue
|
||||
return value.zfill(2)
|
||||
return "01"
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user