mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(bilibili): 为排行榜获取详细的视频描述和发布时间 (#2883)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const got = require('@/utils/got');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rid = ctx.params.rid || '0';
|
||||
@@ -7,7 +8,7 @@ module.exports = async (ctx) => {
|
||||
const arc_type1 = arc_type === '0' ? '全部投稿' : '近期投稿';
|
||||
const rid_1 = ['0', '1', '168', '3', '129', '4', '36', '160', '119', '155', '5', '181'];
|
||||
const rid_2 = ['全站', '动画', '国创相关', '音乐', '舞蹈', '游戏', '科技', '生活', '鬼畜', '时尚', '娱乐', '影视'];
|
||||
const rid_i = rid_1.indexOf(arc_type);
|
||||
const rid_i = rid_1.indexOf(rid + '');
|
||||
const rid_type = rid_2[rid_i];
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
@@ -27,15 +28,11 @@ module.exports = async (ctx) => {
|
||||
list = list.concat(list[i].others);
|
||||
}
|
||||
}
|
||||
|
||||
list = list.map((i) => i.aid);
|
||||
const resultItems = await utils.ProcessFeed(list, ctx.cache);
|
||||
ctx.state.data = {
|
||||
title: `bilibili ${day}日排行榜-${rid_type}-${arc_type1}`,
|
||||
link: `https://www.bilibili.com/ranking/all/${rid}/0/${day}`,
|
||||
item: list.map((item) => ({
|
||||
title: item.title,
|
||||
description: `作者:${item.author}<br>播放量:${item.play}<br>时长:${item.duration}<br>综合得分:${item.pts}<br>弹幕:${item.video_review}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
|
||||
link: `https://www.bilibili.com/video/av${item.aid}`,
|
||||
author: item.author,
|
||||
})),
|
||||
item: resultItems,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
async function load(aid) {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.bilibili.com/x/article/archives?ids=${aid}`,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
const ProcessFeed = async (list, caches) =>
|
||||
await Promise.all(
|
||||
list
|
||||
.filter(async (aid) => {
|
||||
const data = await caches.tryGet('av' + aid, async () => await load(aid));
|
||||
return data.code == 0;
|
||||
})
|
||||
.map(async (aid) => {
|
||||
let data = await caches.tryGet('av' + aid, async () => await load(aid));
|
||||
data = data.data[aid + ''];
|
||||
const single = {
|
||||
title: data.title,
|
||||
description: data.desc,
|
||||
pubDate: new Date(data.pubdate * 1000).toUTCString(),
|
||||
author: data.owner.name,
|
||||
link: `https://www.bilibili.com/video/av${aid}`,
|
||||
guid: `https://www.bilibili.com/video/av${aid}`,
|
||||
};
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
module.exports = {
|
||||
ProcessFeed,
|
||||
};
|
||||
Reference in New Issue
Block a user