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
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
const got = require('@/utils/got');
|
|
const utils = require('./utils');
|
|
|
|
module.exports = async (ctx) => {
|
|
const tid = ctx.params.tid;
|
|
const disableEmbed = ctx.params.disableEmbed;
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url: `https://api.bilibili.com/x/web-interface/newlist?ps=15&rid=${tid}&_=${+new Date()}`,
|
|
headers: {
|
|
Referer: 'https://www.bilibili.com/',
|
|
},
|
|
});
|
|
|
|
const list = response.data.data.archives;
|
|
let name = '未知';
|
|
if (list && list[0] && list[0].tname) {
|
|
name = list[0].tname;
|
|
}
|
|
|
|
ctx.state.data = {
|
|
title: `bilibili ${name}分区`,
|
|
link: 'https://www.bilibili.com',
|
|
description: `bilibili ${name}分区`,
|
|
item:
|
|
list &&
|
|
list.map((item) => ({
|
|
title: item.title,
|
|
description: `${item.desc}${!disableEmbed ? `<br><br>${utils.iframe(item.aid)}` : ''}<br><img src="${item.pic}">`,
|
|
pubDate: new Date(item.pubdate * 1000).toUTCString(),
|
|
link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
|
|
author: item.owner.name,
|
|
})),
|
|
};
|
|
};
|