Skip to content

feat(providers): use Bangumi structured staffs for authors and name_cn mapping - #25

Merged
dyphire merged 4 commits into
masterfrom
feat/bangumi-staffs-persons
Oct 30, 2026
Merged

dyphire merged 4 commits into
masterfrom
feat/bangumi-staffs-persons

Conversation

@dyphire

@dyphire dyphire commented Oct 30, 2026

Copy link
Copy Markdown
Owner

(原 #24,已 rebase 到 master 重开)

概要

利用 Next API 的 GET /p1/subjects/{id}/staffs/persons 结构化人物关联,把 archive 离线路径的 person 增强平移到在线路径。

内容

  • 新增 BangumiClient::get_subject_staffs(分页 limit=100,页间限流),NextSubjectStaff → archive 同构 PersonInfo:一人多职务拆多条(作者 2001 + 原作 2007 → 两行),nameCN/career/appearEps 透出
  • 入库前对 name/nameCN 跑共享清理链(cleaned_person_name):实测 API 的 nameCN 常带消歧注记("星野真(动画人)"),不清理则 publisher_display_name 的精确匹配静默失效
  • 接线 3 处在线流程:get_series_metadata / match_series_metadata → to_series_metadata_persons;get_book_metadata → to_book_metadata_persons(单行本无自身人物关联时回退系列 staffs,对齐 archive 语义)
  • staffs 拉取失败降级为现有 infobox 解析,不阻塞元数据

边界:出版社分类不变

实测确认结构化数据不分原版/代理版:ONE PIECE 的 5 家出版社全部平铺 position=2004 且顺序不分主次(集英社排最后)。因此 Original/Localized 分类仍由 infobox「出版社」/「其他出版社」键语义唯一决定,2004 条目仅参与 publisher_display_name 的 name_cn 显示名映射——与 archive 路径同一边界。

已知缺口

在线路径不解析笔名(pen_name 置空):staffs 返回的 SlimPerson 不含 infobox 别名,笔名需逐人调 /p1/persons/{id}(N+1)。实测 wiki 惯例是条目直接挂笔名记录(如链锯人挂「藤本タツキ」而非本名「藤本樹」),影响面小;如需补齐可作后续(仅对作者职务 person 拉详情)。

测试

  • next_staffs_adapt_persons:多职务拆分、出版社 2004、nameCN 注记剥除、publisher_display_name 匹配闭环
  • cargo test -p komf-core:287 passed / 0 failed;clippy 无新增警告;rustfmt 干净

…n mapping

Fetch /p1/subjects/{id}/staffs/persons and map each person+position to
the archive-shaped PersonInfo, bringing the offline archive's person
enhancement to the online path: structured author/artist/translator
entities (no more infobox key enumeration for them) and nameCN display
names under the staffChineseNames switch.

Publisher classification is unchanged: Original/Localized still comes
from the infobox 出版社/其他出版社 key semantics — position 2004 entries
are flat and unordered in the API, so structured data is only used for
name_cn display mapping (same boundary as the archive path).

Books without their own staff relations fall back to the series staffs,
mirroring the archive fallback. Staffs fetch failures never block
metadata (empty persons degrade to the existing infobox parsing).
Next API person nameCN often carries disambiguation annotations
(e.g. 星野真(动画人), verified live). publisher_display_name matches
persons by exact name/name_cn against infobox publisher strings, so an
annotated nameCN never matches. Run the shared clean_author_names chain
(cleaned_person_name) on name/name_cn at ingest; display-side cleaning
in person_display_name remains and is idempotent.
Staffs can carry dirty records with two people crammed into one name
("A・B"). cleaned_person_name kept only the first segment, silently
dropping the collaborator. Run the full clean_author_names split at
ingest and emit one PersonInfo per segment per position, matching the
infobox author semantics. name_cn cannot be attributed to individual
segments reliably, so it is kept only for single-segment names.
… names only

Not every author has a standalone person record on Bangumi, so sourcing
authors from staffs alone would silently drop them. The online flows now
use to_*_persons_online: authors are still extracted from the infobox
(roles, multi-value splitting unchanged) and structured persons only map
display names via name_cn when the infobox name matches a person with an
author-class position (2001/2002/2003/2007/2009/2010) — the same
boundary publishers already follow. Archive paths keep persons-primary
semantics via to_*_persons.
@dyphire
dyphire merged commit dacc92f into master Oct 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant