From e67950b4312176da8af2acf9493527ffb0427440 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Mon, 1 Apr 2024 21:09:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20bilibili?= =?UTF-8?q?=20=E5=8A=A8=E6=80=81=E8=B7=AF=E7=94=B1=20=E7=BC=BA=E5=A4=B1=20?= =?UTF-8?q?live=5Frcmd=20=E7=B1=BB=E5=9E=8B=E7=9A=84=E9=97=AE=E9=A2=98;=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20title=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/bilibili/dynamic.ts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/routes/bilibili/dynamic.ts b/lib/routes/bilibili/dynamic.ts index e2202794e..ab1420084 100644 --- a/lib/routes/bilibili/dynamic.ts +++ b/lib/routes/bilibili/dynamic.ts @@ -61,12 +61,16 @@ const getTitle = (data: Modules) => { if (!major) { return ''; } - if (major.type === 'MAJOR_TYPE_NONE') { - return major.none?.tips; + if (major.none) { + return major.none.tips; } - if (major.type === 'MAJOR_TYPE_COURSES') { + if (major.courses) { return `${major.courses?.title} - ${major.courses?.sub_title}`; } + if (major.live_rcmd?.content) { + // 正在直播的动态 + return JSON.parse(major.live_rcmd.content)?.live_play_info?.title; + } const type = major.type.replace('MAJOR_TYPE_', '').toLowerCase(); return major[type]?.title; }; @@ -85,10 +89,15 @@ const getDes = (data: Modules) => { desc += desc ? `
//转发自: ${major.common.desc}` : major.common.desc; return desc; } - // 直播动态 + // 转发的直播间 if (major?.live) { return `${major.live?.desc_first}
${major.live?.desc_second}`; } + // 正在直播的动态 + if (major.live_rcmd?.content) { + const live_play_info = JSON.parse(major.live_rcmd.content)?.live_play_info; + return `${live_play_info?.area_name} · ${live_play_info?.watched_show?.text_large}`; + } // 图文动态 if (major?.opus) { return major?.opus?.summary?.text; @@ -130,6 +139,10 @@ const getImgs = (data: Modules) => { if (major.draw?.items?.length) { imgUrls.push(...major.draw.items.map((e) => e.src)); } + // 正在直播的动态 + if (major.live_rcmd?.content) { + return JSON.parse(major.live_rcmd.content)?.live_play_info?.cover; + } const type = major.type.replace('MAJOR_TYPE_', '').toLowerCase(); if (major[type]?.cover) { imgUrls.push(major[type].cover); @@ -271,6 +284,7 @@ async function handler(ctx) { // emoji let description = getDes(data) || ''; + const title = getTitle(data) || description; // 换行处理 description = description.replaceAll('\r\n', '
').replaceAll('\n', '
'); if (data.module_dynamic?.desc?.rich_text_nodes?.length && showEmoji) { @@ -325,7 +339,7 @@ async function handler(ctx) { } const imgHTMLSource = imgHTML ? `
${imgHTML}` : ''; return { - title: getTitle(data) || description, + title, description: `${description}${originDescription}
${urlText}${getIframe(data, disableEmbed)}${getIframe(origin, disableEmbed)}${imgHTMLSource}`, pubDate: data.module_author?.pub_ts ? parseDate(data.module_author.pub_ts, 'X') : undefined, link, From 6981ec625c690a992402c5b27d824f5ca5348f04 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Mon, 1 Apr 2024 21:14:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20=E6=AD=A3?= =?UTF-8?q?=E5=9C=A8=E7=9B=B4=E6=92=AD=E7=9A=84=E5=8A=A8=E6=80=81=20?= =?UTF-8?q?=E5=B0=81=E9=9D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/bilibili/dynamic.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/routes/bilibili/dynamic.ts b/lib/routes/bilibili/dynamic.ts index ab1420084..d51d5c2fa 100644 --- a/lib/routes/bilibili/dynamic.ts +++ b/lib/routes/bilibili/dynamic.ts @@ -141,7 +141,7 @@ const getImgs = (data: Modules) => { } // 正在直播的动态 if (major.live_rcmd?.content) { - return JSON.parse(major.live_rcmd.content)?.live_play_info?.cover; + imgUrls.push(JSON.parse(major.live_rcmd.content)?.live_play_info?.cover); } const type = major.type.replace('MAJOR_TYPE_', '').toLowerCase(); if (major[type]?.cover) { From 653a5aeff43087d26d352d8b8fd24ead30090c59 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Mon, 1 Apr 2024 21:27:23 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix(route):=20=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=20=E6=AD=A3=E5=9C=A8=E7=9B=B4=E6=92=AD=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E7=9B=B4=E6=92=AD=E9=97=B4=E7=9A=84=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/bilibili/dynamic.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/routes/bilibili/dynamic.ts b/lib/routes/bilibili/dynamic.ts index d51d5c2fa..66bb53f4b 100644 --- a/lib/routes/bilibili/dynamic.ts +++ b/lib/routes/bilibili/dynamic.ts @@ -96,7 +96,7 @@ const getDes = (data: Modules) => { // 正在直播的动态 if (major.live_rcmd?.content) { const live_play_info = JSON.parse(major.live_rcmd.content)?.live_play_info; - return `${live_play_info?.area_name} · ${live_play_info?.watched_show?.text_large}`; + return `${live_play_info?.area_name}·${live_play_info?.watched_show?.text_large}`; } // 图文动态 if (major?.opus) { @@ -208,6 +208,12 @@ const getUrl = (item?: Item2, useAvid = false) => { url = `https://live.bilibili.com/${major?.live?.id}`; text = `
直播间地址:${url}`; break; + case 'MAJOR_TYPE_LIVE_RCMD': { + const live_play_info = JSON.parse(major.live_rcmd?.content || '{}')?.live_play_info; + url = `https://live.bilibili.com/${live_play_info?.room_id}`; + text = `
直播间地址:${url}`; + break; + } default: return null; }