mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
Update followings_dynamic.js
优化代码
This commit is contained in:
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
|
|||||||
const uid = String(ctx.params.uid);
|
const uid = String(ctx.params.uid);
|
||||||
const disableEmbed = ctx.params.disableEmbed;
|
const disableEmbed = ctx.params.disableEmbed;
|
||||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||||
|
|
||||||
const cookie = config.bilibili.cookies[uid];
|
const cookie = config.bilibili.cookies[uid];
|
||||||
if (cookie === undefined) {
|
if (cookie === undefined) {
|
||||||
throw Error('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');
|
throw Error('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');
|
||||||
@@ -33,11 +33,8 @@ module.exports = async (ctx) => {
|
|||||||
description: `${name} 关注的动态`,
|
description: `${name} 关注的动态`,
|
||||||
item: data.map((item) => {
|
item: data.map((item) => {
|
||||||
const parsed = JSONbig.parse(item.card);
|
const parsed = JSONbig.parse(item.card);
|
||||||
const data = parsed.item || parsed;
|
const data = parsed.apiSeasonInfo || parsed.item || parsed;
|
||||||
const origin = parsed.origin ? JSONbig.parse(parsed.origin) : null;
|
const origin = parsed.origin ? JSONbig.parse(parsed.origin) : null
|
||||||
|
|
||||||
// 番剧标题
|
|
||||||
const bangumi_title = parsed.apiSeasonInfo || parsed;
|
|
||||||
|
|
||||||
// img
|
// img
|
||||||
let imgHTML = '';
|
let imgHTML = '';
|
||||||
@@ -96,7 +93,7 @@ module.exports = async (ctx) => {
|
|||||||
link = `https://t.bilibili.com/${item.desc.dynamic_id}`;
|
link = `https://t.bilibili.com/${item.desc.dynamic_id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTitle = (data) => bangumi_title.title || data.title || data.description || data.content || (data.vest && data.vest.content) || '';
|
const getTitle = (data) => data.title || data.description || data.content || (data.vest && data.vest.content) || '';
|
||||||
const getDes = (data) =>
|
const getDes = (data) =>
|
||||||
data.dynamic || data.desc || data.description || data.content || data.summary || (data.vest && data.vest.content) + (data.sketch && `<br>${data.sketch.title}<br>${data.sketch.desc_text}`) || data.intro || '';
|
data.dynamic || data.desc || data.description || data.content || data.summary || (data.vest && data.vest.content) + (data.sketch && `<br>${data.sketch.title}<br>${data.sketch.desc_text}`) || data.intro || '';
|
||||||
const getOriginDes = (data) => (data && (data.apiSeasonInfo && data.apiSeasonInfo.title && `//转发自: ${data.apiSeasonInfo.title}`) + (data.index_title && `<br>${data.index_title}`)) || '';
|
const getOriginDes = (data) => (data && (data.apiSeasonInfo && data.apiSeasonInfo.title && `//转发自: ${data.apiSeasonInfo.title}`) + (data.index_title && `<br>${data.index_title}`)) || '';
|
||||||
@@ -115,12 +112,12 @@ module.exports = async (ctx) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 作者信息
|
//作者信息
|
||||||
let author = "哔哩哔哩番剧";
|
let author = "哔哩哔哩番剧"
|
||||||
if (item.desc.user_profile) {
|
if (item.desc.user_profile) {
|
||||||
author = item.desc.user_profile.info.uname;}
|
author = item.desc.user_profile.info.uname;}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: getTitle(data),
|
title: getTitle(data),
|
||||||
author : author,
|
author : author,
|
||||||
@@ -129,8 +126,8 @@ module.exports = async (ctx) => {
|
|||||||
}${getIframe(data)}${getIframe(origin)}${imgHTML ? `<br>${imgHTML}` : ''}${videoHTML ? `<br>${videoHTML}` : ''}`,
|
}${getIframe(data)}${getIframe(origin)}${imgHTML ? `<br>${imgHTML}` : ''}${videoHTML ? `<br>${videoHTML}` : ''}`,
|
||||||
pubDate: new Date(item.desc.timestamp * 1000).toUTCString(),
|
pubDate: new Date(item.desc.timestamp * 1000).toUTCString(),
|
||||||
link: link,
|
link: link,
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user