fix(music): strip Gazelle slash-separated release specs

This commit is contained in:
jxxghp
2026-10-20 12:09:50 +08:00
parent 80a92ddb29
commit d0f70e45eb
3 changed files with 58 additions and 2 deletions

View File

@@ -8263,7 +8263,7 @@
"subtitle": "朴树 - 猎户星座 [2017] [专辑] FLAC / Lossless / Log (100%) / Cue",
"id": "torrent-1126",
"expected": {
"title": "Lie Hu Xing Zuo",
"title": "猎户星座",
"artists": [
"Pu Shu"
],

View File

@@ -9,6 +9,7 @@ from app.chain.search import SearchChain
from app.domain.context import MusicInfo, TorrentInfo
from app.domain.meta import runtime
from app.domain.meta.metamusic import MetaMusic
from app.domain.metainfo import MetaInfo
from app.domain.music import match_music_resource
from app.schemas.types import MediaType
@@ -125,3 +126,44 @@ def test_release_names_without_group_or_cjk_credit(title, artists):
"""
meta = MetaMusic.parse_resource(title)
assert (meta.title, meta.artists, meta.year, meta.audio_format) == ("Album", artists, 2022, "FLAC")
@pytest.mark.usefixtures("music_engine")
@pytest.mark.parametrize("title,expected,year", [
(
"程响 (Cheng Xiang) - 江南多雨时 [2020] [单曲专辑] FLAC / Lossless / WEB / 2020",
"江南多雨时", 2020,
),
(
"群星 (Various Artists) - âge 20th Archives Song Archives [2020] [合辑] "
"FLAC / Lossless / Log (100%) / Cue / CD / 2020",
"âge 20th Archives Song Archives", 2020,
),
(
"群星 - 南泥湾 (Nanni Bay) [1990] [专辑] "
"FLAC / Lossless / Log (100%) / Cue / CD / 自抓 / 1990",
"南泥湾 (Nanni Bay)", 1990,
),
("Artist - Album FLAC / Lossless / WEB / 2020", "Album", 2020),
("Artist - Example Album [2020] FLAC / Lossless / Log (100%) / Cue / CD", "Example Album", 2020),
("Artist - Love / Hate [2020] FLAC / Lossless / WEB / 2020", "Love / Hate", 2020),
("Artist - Captain's Log (100%) [2020] FLAC / Lossless / CD / 2020", "Captain's Log (100%)", 2020),
("Artist - CD [2020] FLAC / Lossless / CD / 2020", "CD", 2020),
("Artist - Album (Live) [2020] FLAC / Lossless / WEB / 2020", "Album (Live)", 2020),
])
def test_gazelle_slash_specs_preserve_music_identity(title: str, expected: str, year: int) -> None:
"""
Gazelle 规格尾链不进入作品名,正文斜杠、抓轨同名词与版本说明仍须保留。
:param title: 含规格尾链的站点资源标题
:param expected: 应保留的真实作品名
:param year: 应提取的发行年份
"""
meta = MetaInfo(title, mtype=MediaType.MUSIC)
assert meta.title == expected
assert meta.year == year
assert meta.org_string == title
assert meta.artists == [title.partition(" - ")[0]]
assert meta.audio_format == "FLAC"
assert meta.audio_lossless is True