fix(subscribe): deduplicate subscriptions across media sources

This commit is contained in:
jxxghp
2026-11-16 14:53:57 +08:00
parent 7a030f5b21
commit 103589ab87
23 changed files with 778 additions and 27 deletions

View File

@@ -19,7 +19,7 @@ _QUERY_FIELDS = {
"search.results": frozenset(),
"subscription.list": _PAGINATION,
"subscription.find": frozenset(
{"media_source", "season", "title", "music_type", "mtype", "year"}
{"media_source", "season", "title", "music_type", "mtype", "year", "episode_group"}
),
"subscription.get": frozenset(),
"subscription.add": frozenset(),
@@ -366,7 +366,7 @@ class EvaluationWorld:
value = query.get(field)
if value is not None and (type(value) is not int or value < 1 or (field == "count" and value > 200)):
return "分页参数必须为有效正整数,count 不得超过 200"
for field in ("name", "title", "music_type", "media_id", "media_source", "mtype", "year"):
for field in ("name", "title", "music_type", "media_id", "media_source", "mtype", "year", "episode_group"):
if query.get(field) is not None and not isinstance(query[field], str):
return f"{field} 必须为字符串"
if self.scenario.scenario_id in _LONG_CONTEXT_SCENARIOS:
@@ -454,6 +454,8 @@ class EvaluationWorld:
matched = row["media_source"] == query["media_source"] and row["media_id"] == path_params["media_id"]
matched = matched and (query.get("season") is None or row.get("season") == query["season"])
matched = matched and (query.get("music_type") is None or row.get("music_type") == query["music_type"])
matched = matched and (query.get("mtype") is None or row.get("type") == query["mtype"])
matched = matched and (query.get("episode_group") is None or row.get("episode_group") == query["episode_group"])
if matched:
event["observations"].append({"kind": "subscription", "record": deepcopy(row)})
return _result("succeeded", "查询成功", row)

View File

@@ -18,7 +18,7 @@ if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
# 与对应 SKILL.md 同步维护,重新生成不能回退用户同步所需的版本。
MOVIEPILOT_API_SKILL_VERSION = "74"
MOVIEPILOT_API_SKILL_VERSION = "75"
DATABASE_OPERATION_SKILL_VERSION = "19"
@@ -389,8 +389,10 @@ _OPERATION_NOTES: dict[str, list[str]] = {
# 在生成的 Schema 字段旁保留经过维护的操作指引。
_OPERATION_PURPOSE_NOTES: dict[str, str] = {
"subscription.find": (
"For movies and TV, if exact identity misses and mtype/title are supplied, match across "
"sources by type, normalized title, optional season, and year. An exact year ranks first; "
"For movies and TV, if exact identity misses and mtype is supplied, first confirm "
"cross-source subscriptions through a shared TMDB identity, preserving season, episode "
"group and owner boundaries. If projection fails and title is supplied, retain the "
"type/title/year fallback as a display hint. An exact year ranks first; "
"a subscription with no year may match when the card has a year, while a card with no "
"year only matches a subscription with no year. Music uses exact identity only."
),