mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-19 05:03:57 +08:00
fix(music): 署名前缀剥离与候选首段弱匹配修复失配
- 曲名开头的艺术家署名前缀(许茹芸的爱情电影主题曲)是命名习惯, 检索式与候选比对统一用剥离后的主体名,署名身份由艺术家要求保证 - 条目「主体名 补充说明」结构(愛情電影主題曲 雲且留住)首段一致视为弱匹配 - 采样率支持空格写法(44 1khz),合集/精选纳入发行形态标记剔除 - 规格剔除后仅剩悬空分隔符时仍拆出艺术家(周杰伦 - 合集 2000-2022) - 修正合集修饰词正则中的杂空格
This commit is contained in:
@@ -390,3 +390,14 @@ def test_apply_title_keeps_single_paren_disambiguation():
|
||||
|
||||
assert meta.artists == ["周杰伦"]
|
||||
assert meta.title == "晴天 (电影版)"
|
||||
|
||||
|
||||
def test_apply_title_collection_with_space_sample_rate():
|
||||
"""合集/精选是发行形态标记,空格写法的采样率(44 1khz)也应剔除;
|
||||
剔除后仅剩悬空分隔符时艺术家仍需拆出。"""
|
||||
meta = parse_title("周杰伦 - 合集 2000-2022 - FLAC 16bit 44 1khz")
|
||||
|
||||
assert meta.artists == ["周杰伦"]
|
||||
assert meta.title is None
|
||||
assert meta.year == 2022
|
||||
assert meta.audio_format == "FLAC"
|
||||
|
||||
@@ -634,6 +634,33 @@ def test_same_text_normalizes_cjk_numerals():
|
||||
assert not MusicBrainzModule._same_text("茹此精彩十三首", "茹此精彩14首")
|
||||
|
||||
|
||||
def test_strip_artist_prefix_removes_signature_prefix():
|
||||
"""曲名开头的艺术家署名前缀是命名习惯,检索与比对应使用主体名。"""
|
||||
assert MusicBrainzModule._strip_artist_prefix(
|
||||
"许茹芸的爱情电影主题曲", ["许茹芸"]) == "爱情电影主题曲"
|
||||
# 剥离后无剩余时保留原标题,短标题不受影响
|
||||
assert MusicBrainzModule._strip_artist_prefix("许茹芸", ["许茹芸"]) == "许茹芸"
|
||||
assert MusicBrainzModule._strip_artist_prefix("晴天", ["周杰伦"]) == "晴天"
|
||||
|
||||
|
||||
def test_select_album_candidate_matches_lead_token_structure():
|
||||
"""条目「主体名 补充说明」结构与资源主体名首段一致时应弱匹配命中。"""
|
||||
meta = MetaMusic(title="许茹芸的爱情电影主题曲", artists=["许茹芸"], year=2003)
|
||||
album = MusicInfo(
|
||||
source="musicbrainz",
|
||||
music_type="album",
|
||||
media_id="album-1",
|
||||
title="愛情電影主題曲 雲且留住",
|
||||
artists=["許茹芸"],
|
||||
year=2003,
|
||||
)
|
||||
|
||||
matched = MusicBrainzModule._select_album_candidate(meta, [album])
|
||||
|
||||
assert matched is not None
|
||||
assert matched.media_id == "album-1"
|
||||
|
||||
|
||||
def test_select_candidate_rejects_wrong_artist_same_title():
|
||||
"""已知艺术家时,同名异曲的候选不能因标题相等被采信。"""
|
||||
meta = MetaMusic(title="因为有你", artists=["毛阿敏"])
|
||||
|
||||
Reference in New Issue
Block a user