add bilibili ranking

This commit is contained in:
DIYgod 2018-07-17 01:29:45 +08:00
parent 1819a4bedf
commit fcfc14eae3
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
4 changed files with 55 additions and 0 deletions

View File

@ -33,6 +33,7 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 主站话题列表
- 会员购新品上架
- 会员购作品
- 排行榜
- 微博
- 博主
- 关键词

View File

@ -333,6 +333,22 @@ order: 排序方式live_time 开播时间online 人气
参数: id, 作品 id, 可在作品列表页 URL 中找到
### 排行榜
举例: [https://rsshub.app/bilibili/ranking/0/3](https://rsshub.app/bilibili/ranking/0/3)
路由: `/bilibili/ranking/:rid?/:day?`
参数:
day: 时间跨度,可为 1 3 7 30
rid: 排行榜分区 id默认 0
| 全站 | 动画 | 国创相关 | 音乐 | 舞蹈 | 游戏 | 科技 | 生活 | 鬼畜 | 时尚 | 娱乐 | 影视 |
| ---- | ---- | -------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| 0 | 1 | 168 | 3 | 129 | 4 | 36 | 160 | 119 | 155 | 5 | 181 |
## bangumi
### 放送列表

View File

@ -103,6 +103,7 @@ router.get('/bilibili/fav/:uid/:fid', require('./routes/bilibili/fav'));
router.get('/bilibili/blackboard', require('./routes/bilibili/blackboard'));
router.get('/bilibili/mall/new', require('./routes/bilibili/mallNew'));
router.get('/bilibili/mall/ip/:id', require('./routes/bilibili/mallIP'));
router.get('/bilibili/ranking/:rid?/:day?', require('./routes/bilibili/ranking'));
// bangumi
router.get('/bangumi/calendar/today', require('./routes/bangumi/calendar/today'));

View File

@ -0,0 +1,37 @@
const axios = require('../../utils/axios');
const config = require('../../config');
module.exports = async (ctx) => {
const rid = ctx.params.rid || '0';
const day = ctx.params.day || '3';
const response = await axios({
method: 'get',
url: `https://api.bilibili.com/x/web-interface/ranking?jsonp=jsonp&rid=${rid}&day=${day}&type=1&arc_type=0&callback=__jp0`,
headers: {
'User-Agent': config.ua,
Referer: `https://www.bilibili.com/ranking/all/${rid}/0/${day}`,
},
});
const data = JSON.parse(response.data.match(/^__jp0\((.*)\)$/)[1]).data || {};
let list = data.list || [];
for (let i = 0; i < list.length; i++) {
if (list[i].others && list[i].others.length) {
list[i].others.forEach((item) => {
item.author = list[i].author;
});
list = list.concat(list[i].others);
}
}
ctx.state.data = {
title: `bilibili ${day}日排行榜-${rid}`,
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><img referrerpolicy="no-referrer" src="${item.pic}">`,
link: `https://www.bilibili.com/video/av${item.aid}`,
})),
};
};