Merge pull request #15046 from CaoMeiYouRen/fix/bilibili/user/dynamic-v2
fix(route): 修复 bilibili 动态路由 缺失 live_rcmd 类型的问题; 修复 title 问题
This commit is contained in:
@@ -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 ? `<br>//转发自: ${major.common.desc}` : major.common.desc;
|
||||
return desc;
|
||||
}
|
||||
// 直播动态
|
||||
// 转发的直播间
|
||||
if (major?.live) {
|
||||
return `${major.live?.desc_first}<br>${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) {
|
||||
imgUrls.push(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);
|
||||
@@ -195,6 +208,12 @@ const getUrl = (item?: Item2, useAvid = false) => {
|
||||
url = `https://live.bilibili.com/${major?.live?.id}`;
|
||||
text = `<br>直播间地址:<a href=${url}>${url}</a>`;
|
||||
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 = `<br>直播间地址:<a href=${url}>${url}</a>`;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -271,6 +290,7 @@ async function handler(ctx) {
|
||||
|
||||
// emoji
|
||||
let description = getDes(data) || '';
|
||||
const title = getTitle(data) || description;
|
||||
// 换行处理
|
||||
description = description.replaceAll('\r\n', '<br>').replaceAll('\n', '<br>');
|
||||
if (data.module_dynamic?.desc?.rich_text_nodes?.length && showEmoji) {
|
||||
@@ -325,7 +345,7 @@ async function handler(ctx) {
|
||||
}
|
||||
const imgHTMLSource = imgHTML ? `<br>${imgHTML}` : '';
|
||||
return {
|
||||
title: getTitle(data) || description,
|
||||
title,
|
||||
description: `${description}${originDescription}<br>${urlText}${getIframe(data, disableEmbed)}${getIframe(origin, disableEmbed)}${imgHTMLSource}`,
|
||||
pubDate: data.module_author?.pub_ts ? parseDate(data.module_author.pub_ts, 'X') : undefined,
|
||||
link,
|
||||
|
||||
Reference in New Issue
Block a user