fix/various fixes

This commit is contained in:
Kevin
2026-03-20 15:15:35 +08:00
parent 7f57f96c25
commit 7317bf10cd
112 changed files with 3790 additions and 2242 deletions

View File

@@ -34,15 +34,19 @@ def collect_asset_ids_from_markdown(markdown: str) -> list[str]:
def collect_asset_ids_for_chapter(chapter) -> set[str]:
"""章节正文canonical + 各 sectioncover_asset_id 中出现的 asset id。"""
"""章节正文 canonical、收录的各 story 正文、cover_asset_id 中的 asset id。"""
ids: set[str] = set()
md = getattr(chapter, "canonical_markdown", None) or ""
ids.update(collect_asset_ids_from_markdown(md))
for sec in getattr(chapter, "sections", None) or []:
ids.update(collect_asset_ids_from_markdown(getattr(sec, "content", None) or ""))
cid = getattr(chapter, "cover_asset_id", None)
if cid:
ids.add(str(cid))
for link in getattr(chapter, "story_links", None) or []:
st = getattr(link, "story", None)
if st is None:
continue
smd = getattr(st, "canonical_markdown", None) or ""
ids.update(collect_asset_ids_from_markdown(smd))
return ids