mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-02 05:37:14 +08:00
fix(parser): preserve CJK movie words in titles
This commit is contained in:
@@ -71,7 +71,10 @@ _PV = re.compile(
|
||||
)
|
||||
_NCOP = re.compile(r"(?<![A-Za-z0-9])NCOP(?:v?(\d+))?(?![A-Za-z0-9])", re.I)
|
||||
_NCED = re.compile(r"(?<![A-Za-z0-9])NCED(?:v?(\d+))?(?![A-Za-z0-9])", re.I)
|
||||
_MOVIE_CJK = re.compile(r"劇場版?|剧场版?|電影版|电影版")
|
||||
_MOVIE_CJK = re.compile(
|
||||
r"劇場版|剧场版|電影版|电影版|"
|
||||
r"(?<![\u3400-\u9fff])(?:劇場|剧场)(?![\u3400-\u9fff])"
|
||||
)
|
||||
_MOVIE_ROMAJI = re.compile(r"(?<!\w)Gekijou-?ban(?!\w)", re.I)
|
||||
_MOVIE_EN = re.compile(r"(?<!\w)(?:The\s+)?Movie(?!\w)", re.I)
|
||||
|
||||
|
||||
@@ -103,7 +103,10 @@ _PV = re.compile(
|
||||
)
|
||||
_NCOP = re.compile(r"(?<![A-Za-z0-9])NCOP(?:v?(\d+))?(?![A-Za-z0-9])", re.I)
|
||||
_NCED = re.compile(r"(?<![A-Za-z0-9])NCED(?:v?(\d+))?(?![A-Za-z0-9])", re.I)
|
||||
_MOVIE_CJK = re.compile(r"劇場版?|剧场版?|電影版|电影版")
|
||||
_MOVIE_CJK = re.compile(
|
||||
r"劇場版|剧场版|電影版|电影版|"
|
||||
r"(?<![\u3400-\u9fff])(?:劇場|剧场)(?![\u3400-\u9fff])"
|
||||
)
|
||||
_MOVIE_ROMAJI = re.compile(r"(?<!\w)Gekijou-?ban(?!\w)", re.I)
|
||||
_MOVIE_EN = re.compile(r"(?<!\w)(?:The\s+)?Movie(?!\w)", re.I)
|
||||
|
||||
|
||||
@@ -95,6 +95,34 @@ def test_classic_and_preview_are_distinct_implementations() -> None:
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"parse",
|
||||
[parse_classic_release_title, selector.preview.parse_release_title],
|
||||
ids=["classic", "preview"],
|
||||
)
|
||||
@pytest.mark.parametrize("title", ["某剧场作品", "小剧场", "某劇場作品", "小劇場"])
|
||||
def test_cjk_movie_word_inside_title_is_not_consumed(parse, title: str) -> None:
|
||||
parsed = parse(f"[SubGroup] {title} Movie [1080p][MP4]")
|
||||
|
||||
assert parsed is not None
|
||||
assert parsed.title_zh == title
|
||||
assert parsed.media_type is MediaType.MOVIE
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"parse",
|
||||
[parse_classic_release_title, selector.preview.parse_release_title],
|
||||
ids=["classic", "preview"],
|
||||
)
|
||||
def test_standalone_cjk_movie_marker_is_still_consumed(parse) -> None:
|
||||
parsed = parse("[SubGroup] 某动画 / Some Anime 剧场 [1080p][MP4]")
|
||||
|
||||
assert parsed is not None
|
||||
assert parsed.title_zh == "某动画"
|
||||
assert parsed.title_en == "Some Anime"
|
||||
assert parsed.media_type is MediaType.MOVIE
|
||||
|
||||
|
||||
def test_selector_uses_classic_without_preview_fallback(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user