mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 15:47:48 +08:00
* feat(route): add bilibili online list * fix(route): bilibili online list * fix(route): bilibili online list * refactor: migrate to v2
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
const got = require('@/utils/got');
|
|
const utils = require('./utils');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
module.exports = async (ctx) => {
|
|
const fid = ctx.params.fid;
|
|
const uid = ctx.params.uid;
|
|
const disableEmbed = ctx.params.disableEmbed;
|
|
|
|
const response = await got({
|
|
url: `https://api.bilibili.com/x/v3/fav/resource/list?media_id=${fid}&ps=20`,
|
|
headers: {
|
|
Referer: `https://space.bilibili.com/${uid}/`,
|
|
},
|
|
});
|
|
const { data, code, message } = response.data;
|
|
if (code) {
|
|
throw new Error(message ? message : code);
|
|
}
|
|
|
|
const userName = data.info.upper.name;
|
|
const favName = data.info.title;
|
|
|
|
ctx.state.data = {
|
|
title: `${userName} 的 bilibili 收藏夹 ${favName}`,
|
|
link: `https://space.bilibili.com/${uid}/#/favlist?fid=${fid}`,
|
|
description: `${userName} 的 bilibili 收藏夹 ${favName}`,
|
|
|
|
item:
|
|
data.medias &&
|
|
data.medias.map((item) => ({
|
|
title: item.title,
|
|
description: `${item.intro}${!disableEmbed ? `<br><br>${utils.iframe(item.id)}` : ''}<br><img src='${item.cover}'>`,
|
|
pubDate: parseDate(item.fav_time * 1000),
|
|
link: item.fav_time > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.id}`,
|
|
author: item.upper.name,
|
|
})),
|
|
};
|
|
};
|