From 77501fd0438ff8b370d5aa3c6250675b2b8b1f4c Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <40430746+CaoMeiYouRen@users.noreply.github.com> Date: Tue, 28 May 2024 13:53:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20bilibili=20=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=B0=86=E8=AF=9D?= =?UTF-8?q?=E9=A2=98=E4=BD=9C=E4=B8=BA=20category=20(#15741)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/bilibili/dynamic.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/routes/bilibili/dynamic.ts b/lib/routes/bilibili/dynamic.ts index 8ec42a6ed..30f056cc1 100644 --- a/lib/routes/bilibili/dynamic.ts +++ b/lib/routes/bilibili/dynamic.ts @@ -275,7 +275,7 @@ async function handler(ctx) { let description = getDes(data) || ''; const title = getTitle(data) || description; // 没有 title 的时候使用 desc 填充 - + const category: string[] = []; // emoji if (data.module_dynamic?.desc?.rich_text_nodes?.length) { const nodes = data.module_dynamic.desc.rich_text_nodes; @@ -301,6 +301,20 @@ async function handler(ctx) { .join('
') ); } + if (node?.type === 'RICH_TEXT_NODE_TYPE_TOPIC') { + // 将话题作为 category + category.push(node.text.match(/#(\S+)#/)?.[1] || ''); + } + } + } + + if (data.module_dynamic?.major?.opus?.summary?.rich_text_nodes?.length) { + const nodes = data.module_dynamic.major.opus.summary.rich_text_nodes; + for (const node of nodes) { + if (node?.type === 'RICH_TEXT_NODE_TYPE_TOPIC') { + // 将话题作为 category + category.push(node.text.match(/#(\S+)#/)?.[1] || ''); + } } } @@ -353,6 +367,7 @@ async function handler(ctx) { pubDate: data.module_author?.pub_ts ? parseDate(data.module_author.pub_ts, 'X') : undefined, link, author, + category: category.length ? category : undefined, }; }) );