mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: optimize bilibili ranking api
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
const got = require('@/utils/got');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rid = ctx.params.rid || '0';
|
||||
@@ -28,11 +27,28 @@ module.exports = async (ctx) => {
|
||||
list = list.concat(list[i].others);
|
||||
}
|
||||
}
|
||||
list = list.map((i) => i.aid);
|
||||
const resultItems = await utils.ProcessFeed(list, ctx.cache);
|
||||
list = list.map((i) => i.aid).slice(0, 100);
|
||||
const detailsResponse = await got({
|
||||
method: 'get',
|
||||
url: `https://api.bilibili.com/x/article/archives?ids=${list.join(',')}`,
|
||||
});
|
||||
ctx.state.data = {
|
||||
title: `bilibili ${day}日排行榜-${rid_type}-${arc_type1}`,
|
||||
link: `https://www.bilibili.com/ranking/all/${rid}/0/${day}`,
|
||||
item: resultItems,
|
||||
item: list.map((aid) => {
|
||||
const data = detailsResponse.data.data[aid];
|
||||
if (data) {
|
||||
return {
|
||||
title: data.title,
|
||||
description: `${data.desc}<br><img src="${data.pic}">`,
|
||||
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}`,
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user