mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-07-04 06:11:29 +08:00
fix: normalize question marks in title matching
This commit is contained in:
@@ -203,7 +203,7 @@ class StringUtils:
|
||||
忽略特殊字符
|
||||
"""
|
||||
# 需要忽略的特殊字符
|
||||
CONVERT_EMPTY_CHARS = r"[、.。,,·::;;!!'’\"“”()()\[\]【】「」\-—―\+\|\\_/&#~~]"
|
||||
CONVERT_EMPTY_CHARS = r"[、.。,,·::;;!!??'’\"“”()()\[\]【】「」\-—―\+\|\\_/&#~~]"
|
||||
if not text:
|
||||
return text
|
||||
if not isinstance(text, list):
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
|
||||
from app.core.metainfo import MetaInfo, MetaInfoPath, find_metainfo
|
||||
from app.helper.torrent import TorrentHelper
|
||||
from app.schemas.types import MediaType
|
||||
from tests.cases.meta import meta_cases
|
||||
|
||||
|
||||
@@ -108,6 +111,52 @@ def test_metainfo_preserves_original_name_when_custom_words_applied():
|
||||
assert meta.original_name == "电影测试替换名称"
|
||||
|
||||
|
||||
def test_torrent_title_match_ignores_question_mark_variants():
|
||||
"""问号差异不应导致番剧罗马字标题匹配失败。"""
|
||||
mediainfo = SimpleNamespace(
|
||||
title="哪里有温柔对待阿宅的辣妹!?",
|
||||
original_title="オタクに優しいギャルはいない!?",
|
||||
names=["Otaku ni Yasashii Gal wa Inai!?"],
|
||||
type=MediaType.TV,
|
||||
year=None,
|
||||
tmdb_id=None,
|
||||
douban_id=None,
|
||||
imdb_id=None,
|
||||
season_years={},
|
||||
)
|
||||
torrent_meta = SimpleNamespace(
|
||||
tmdbid=None,
|
||||
doubanid=None,
|
||||
cn_name=None,
|
||||
en_name="Otaku ni Yasashii Gal wa Inai",
|
||||
type=MediaType.TV,
|
||||
year=None,
|
||||
org_string=None,
|
||||
)
|
||||
torrent = SimpleNamespace(
|
||||
site_name="MiKan",
|
||||
title="[今晚月色真美][Otaku ni Yasashii Gal wa Inai!?][12][1080P]",
|
||||
category=MediaType.TV.value,
|
||||
imdbid=None,
|
||||
description=None,
|
||||
)
|
||||
|
||||
assert TorrentHelper.match_torrent(
|
||||
mediainfo=mediainfo,
|
||||
torrent_meta=torrent_meta,
|
||||
torrent=torrent,
|
||||
)
|
||||
|
||||
mediainfo.names = []
|
||||
torrent_meta.cn_name = "哪里有温柔对待阿宅的辣妹"
|
||||
torrent_meta.en_name = None
|
||||
assert TorrentHelper.match_torrent(
|
||||
mediainfo=mediainfo,
|
||||
torrent_meta=torrent_meta,
|
||||
torrent=torrent,
|
||||
)
|
||||
|
||||
|
||||
def test_custom_words_replace_then_episode_offset():
|
||||
"""测试复杂识别词仍按先替换、后集数偏移的顺序处理。"""
|
||||
custom_words = ["旧名 => 新名 && 第 <> 集 >> EP+1"]
|
||||
|
||||
Reference in New Issue
Block a user