Fix parser (#877)

Thanks for the fix! The improved regex pattern will help parse more anime titles correctly. Closes #876 and #924. 🎉
This commit is contained in:
XYenon
2026-01-26 05:12:43 +08:00
committed by GitHub
parent 0385129f5d
commit 3695452fb7

View File

@@ -7,7 +7,7 @@ logger = logging.getLogger(__name__)
EPISODE_RE = re.compile(r"\d+")
TITLE_RE = re.compile(
r"(.*|\[.*])( -? \d+|\[\d+]|\[\d+.?[vV]\d]|第\d+[话話集]|\[第?\d+[话話集]]|\[\d+.?END]|[Ee][Pp]?\d+)(.*)"
r"(.*?|\[.*])((?: ?-)? ?\d+ |\[\d+]|\[\d+.?[vV]\d]|第\d+[话話集]|\[第?\d+[话話集]]|\[\d+.?END]|[Ee][Pp]?\d+)(.*)"
)
RESOLUTION_RE = re.compile(r"1080|720|2160|4K")
SOURCE_RE = re.compile(r"B-Global|[Bb]aha|[Bb]ilibili|AT-X|Web")
@@ -185,3 +185,7 @@ def raw_parser(raw: str) -> Episode | None:
if __name__ == "__main__":
title = "[动漫国字幕组&LoliHouse] THE MARGINAL SERVICE - 08 [WebRip 1080p HEVC-10bit AAC][简繁内封字幕]"
print(raw_parser(title))
title = "[北宇治字幕组&LoliHouse] 地。-关于地球的运动- / Chi. Chikyuu no Undou ni Tsuite 03 [WebRip 1080p HEVC-10bit AAC ASSx2][简繁日内封字幕]"
print(raw_parser(title))
title = "[御坂字幕组] 男女之间存在纯友情吗?(不,不存在!!-01 [WebRip 1080p HEVC10-bit AAC] [简繁日内封] [急招翻校轴]"
print(raw_parser(title))