mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-12-01 00:15:56 +08:00
fix(music): expose rejected manual candidates and prepare v3.2.9
This commit is contained in:
@@ -243,6 +243,11 @@ def _match_torrents(
|
||||
) -> List[MatchedTorrent]:
|
||||
"""
|
||||
按输入顺序匹配资源,并复用同名候选的识别结果。
|
||||
|
||||
显式人工候选模式会保留全部音乐匹配结论,包括被自动匹配拒绝的资源;
|
||||
这些资源在上下文投影时不会绑定目标媒体,只能由用户确认后继续操作。
|
||||
|
||||
:param include_candidates: 是否保留供用户人工确认的非精确音乐候选
|
||||
"""
|
||||
logger.info(f"开始匹配结果 类型:{(mediainfo.type or MediaType.UNKNOWN).value},标题:{mediainfo.title},别名:{mediainfo.names}")
|
||||
progress.update(value=51, text=f"开始匹配,总 {len(torrents)} 个资源 ...")
|
||||
@@ -273,7 +278,7 @@ def _match_torrents(
|
||||
meta=cast(MetaMusic, meta),
|
||||
)
|
||||
diagnostics[match.reason] += 1
|
||||
if match.status == "exact" or (include_candidates and match.status != "rejected"):
|
||||
if match.status == "exact" or include_candidates:
|
||||
matches.append(MatchedTorrent(torrent, meta, "title", match))
|
||||
else:
|
||||
logger.debug(f"音乐资源 {torrent.site_name} - {torrent.title} 未通过匹配:{match.reason}")
|
||||
|
||||
@@ -101,6 +101,14 @@ Server 使用独立 SQL 表长期保存关系,不属于识别缓存清理范
|
||||
和 Authorization 区分缓存变体;切换身份后重新校验访问。其它业务 API
|
||||
继续按 `no-store` 读取。
|
||||
|
||||
### 音乐资源人工候选
|
||||
|
||||
`GET /api/v1/search/media/{media_id}` 及对应 `/stream` 接口在显式设置
|
||||
`include_candidates=true` 时,保留通过现有筛选规则的非精确音乐资源,包括名称、演出或站点分类
|
||||
与目标不符的资源。它们以 `match_status=candidate` 返回,`match_reason` 保留匹配原因,
|
||||
`media_info` 为空,不会绑定搜索目标身份。前端在“待确认”中展示,下载前仍须人工核对确认。
|
||||
默认精确搜索和自动订阅继续只采用精确匹配结果。
|
||||
|
||||
### iOS 媒体流与电视剧选集
|
||||
|
||||
`GET /api/v1/mediaserver/search?keyword=...&type=电视剧&type=音乐&limit=40` 按关键词调用
|
||||
|
||||
@@ -45,6 +45,8 @@ Identity scope: `bound_user`; required role: `user`.
|
||||
|
||||
#### Candidate Selection and Empty-Result Retries
|
||||
|
||||
With `include_candidates=true`, manually reviewable music candidates also include resources rejected by automatic identity matching. `match_status` is `candidate`, `match_reason` retains the rejection reason (for example `title_mismatch`), and `media_info` is null. Do not treat them as confirmed matches or download them automatically; existing search filters still apply.
|
||||
|
||||
- When `media.search` returns multiple candidates, select based on **title matching the user's request AND `type` (movie/series) matching**; do not mechanically pick the first or an arbitrary candidate without comparison. If the first candidate happens to exactly match and its type is correct, you may use it directly; when several are close, prefer the higher-ranked / more popular one.
|
||||
- `search.torrents` must be called with `media_source` + `media_id`, and both must come from the **same** recognition result — do not mix `source`/`id` from different candidates.
|
||||
- Do not repeat an unchanged empty or failed search without new evidence. On failure, inspect and report the error; an unavailable source does not prove there are no resources.
|
||||
|
||||
@@ -86,6 +86,29 @@ def test_music_manual_candidates_keep_resource_identity_separate():
|
||||
assert candidate.media_info_is_target is False
|
||||
|
||||
|
||||
def test_music_manual_candidates_include_rejected_resources_with_reason():
|
||||
"""
|
||||
显式人工候选搜索应展示自动匹配拒绝的资源,并保留拒绝原因供用户判断。
|
||||
"""
|
||||
chain = SearchChain()
|
||||
target = MusicInfo(title="2026 原音精选")
|
||||
torrent = TorrentInfo(
|
||||
title="VA-2026 The Perfect Sound 原音精選 (香港高級視聽展 SACD)DSF",
|
||||
category=MediaType.MUSIC.value,
|
||||
)
|
||||
|
||||
assert chain._build_music_contexts([torrent], target, rule_groups=[]) == []
|
||||
candidates = chain._build_music_contexts(
|
||||
[torrent], target, rule_groups=[], include_candidates=True,
|
||||
)
|
||||
|
||||
assert len(candidates) == 1
|
||||
assert candidates[0].match_status == "candidate"
|
||||
assert candidates[0].match_reason == "title_mismatch"
|
||||
assert candidates[0].media_info is None
|
||||
assert candidates[0].media_info_is_target is False
|
||||
|
||||
|
||||
def test_music_description_title_is_available_as_manual_candidate():
|
||||
"""
|
||||
描述中的明确专辑名应进入人工候选,不得绕过默认精确搜索安全边界。
|
||||
@@ -107,7 +130,8 @@ def test_music_description_title_is_available_as_manual_candidate():
|
||||
assert candidates[0].media_info is None
|
||||
|
||||
|
||||
def test_music_stream_counts_rejected_site_results():
|
||||
@pytest.mark.parametrize("include_candidates", [False, True])
|
||||
def test_music_stream_counts_rejected_site_results(include_candidates):
|
||||
"""
|
||||
分类和名称不符仍属于站点原始候选,空态应能说明为何没有最终结果。
|
||||
"""
|
||||
@@ -124,13 +148,20 @@ def test_music_stream_counts_rejected_site_results():
|
||||
"""
|
||||
使用显式关键词把样例限定为一次站点查询。
|
||||
"""
|
||||
return [event async for event in chain._async_process_music_stream(target, keyword="One", rule_groups=[])]
|
||||
return [event async for event in chain._async_process_music_stream(
|
||||
target, keyword="One", rule_groups=[], include_candidates=include_candidates,
|
||||
)]
|
||||
|
||||
with patch.object(chain, "_SearchChain__async_search_all_sites_stream", side_effect=batches):
|
||||
events = asyncio.run(collect())
|
||||
assert events[-1]["candidate_items"] == 1
|
||||
assert events[-1]["total_items"] == 0
|
||||
assert events[-1]["total_items"] == int(include_candidates)
|
||||
assert events[-1]["match_counts"] == {"title_mismatch": 1}
|
||||
if include_candidates:
|
||||
candidate = events[-1]["items"][0]
|
||||
assert candidate["match_status"] == "candidate"
|
||||
assert candidate["match_reason"] == "title_mismatch"
|
||||
assert candidate["media_info"] is None
|
||||
|
||||
|
||||
def test_music_context_builder_keeps_only_music_category():
|
||||
|
||||
@@ -18,7 +18,11 @@ from app.schemas.types import MediaSource, MediaType
|
||||
|
||||
@pytest.mark.anyio
|
||||
@pytest.mark.parametrize("include_candidates", [False, True])
|
||||
async def test_music_manual_candidate_opt_in_survives_http_and_serialization(include_candidates):
|
||||
@pytest.mark.parametrize(("resource_title", "reason"), [
|
||||
("Jay Chou - 晴天 FLAC", "artist_unverified"),
|
||||
("U2 - One Tree Hill FLAC", "title_mismatch"),
|
||||
])
|
||||
async def test_music_manual_candidate_opt_in_survives_http_and_serialization(include_candidates, resource_title, reason):
|
||||
"""
|
||||
默认精确搜索不会放行未核验署名,显式人工候选请求保留资源但不绑定目标。
|
||||
"""
|
||||
@@ -29,7 +33,7 @@ async def test_music_manual_candidate_opt_in_survives_http_and_serialization(inc
|
||||
chain._async_save_results = AsyncMock()
|
||||
chain.cancel_ai_recommend = Mock()
|
||||
chain._SearchChain__async_search_all_sites = AsyncMock(return_value=[
|
||||
TorrentInfo(title="Jay Chou - 晴天 FLAC", category=MediaType.MUSIC.value),
|
||||
TorrentInfo(title=resource_title, category=MediaType.MUSIC.value),
|
||||
])
|
||||
metadata = Mock()
|
||||
metadata.async_recognize_media = AsyncMock(return_value=target)
|
||||
@@ -53,9 +57,10 @@ async def test_music_manual_candidate_opt_in_survives_http_and_serialization(inc
|
||||
assert len(payload["data"]) == 1
|
||||
candidate = payload["data"][0]
|
||||
assert candidate["match_status"] == "candidate"
|
||||
assert candidate["match_reason"] == "artist_unverified"
|
||||
assert candidate["match_reason"] == reason
|
||||
assert candidate["media_info"] is None
|
||||
assert candidate["meta_info"]["artists"] == ["Jay Chou"]
|
||||
assert candidate["torrent_info"]["title"] == resource_title
|
||||
assert candidate["meta_info"]["artists"] == [resource_title.split(" - ")[0]]
|
||||
assert candidate["meta_info"]["media_id"] is None
|
||||
assert chain.async_save_last_search_params.call_args.kwargs["include_candidates"] is True
|
||||
else:
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
声明后端与前端发布版本。
|
||||
"""
|
||||
|
||||
APP_VERSION = 'v3.2.8'
|
||||
FRONTEND_VERSION = 'v3.2.8'
|
||||
APP_VERSION = 'v3.2.9'
|
||||
FRONTEND_VERSION = 'v3.2.9'
|
||||
# 本版本要求的最低 Docker 镜像系统基线(ISO 日期),与镜像内 /etc/moviepilot/system-baseline 比较。
|
||||
# 低于该值的镜像拒绝应用内更新,提示用户先更新 Docker 镜像。只在修复严重系统级漏洞时提高,
|
||||
# 且在同一发布中把 docker/system-baseline 改成相同日期,保证新镜像自身满足要求。
|
||||
|
||||
Reference in New Issue
Block a user