add bilibili video reply

This commit is contained in:
qixingchen 2018-05-06 16:49:01 +08:00
parent 1f5171bffc
commit 07a9008be3
4 changed files with 56 additions and 0 deletions

View File

@ -19,6 +19,7 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- UP 主粉丝
- UP 主关注用户
- 分区视频
- 视频评论
- 微博
- 博主
- 网易云音乐

View File

@ -152,6 +152,13 @@ s
| ---- | ---- | ---- | ----- | ---- |
| 182 | 183 | 85 | 184 | 86 |
### 视频评论
举例: https://rss.now.sh/bilibili/video/reply/7
路由: `/bilibili/video/reply/:avid`
参数: avid视频 AV 号(仅数字)
## 微博

View File

@ -19,6 +19,7 @@ router.get('/bilibili/user/followers/:uid', require('./routes/bilibili/followers
router.get('/bilibili/user/followings/:uid', require('./routes/bilibili/followings'));
router.get('/bilibili/partion/:tid', require('./routes/bilibili/partion'));
router.get('/bilibili/bangumi/:seasonid', require('./routes/bilibili/bangumi'));
router.get('/bilibili/video/reply/:avid', require('./routes/bilibili/videoReply'));
// // 微博
router.get('/weibo/user/:uid', require('./routes/weibo/user'));

View File

@ -0,0 +1,47 @@
const axios = require('axios');
const art = require('art-template');
const path = require('path');
const config = require('../../config');
const cheerio = require('cheerio');
const iconv = require('iconv-lite');
module.exports = async (ctx) => {
const avid = ctx.params.avid;
const nameResponse = await axios({
method: 'get',
url: `https://www.bilibili.com/video/av${avid}`,
headers: {
'User-Agent': config.ua,
},
responseType: 'arraybuffer'
});
const responseHtml = iconv.decode(nameResponse.data, 'UTF-8');
const $ = cheerio.load(responseHtml);
let name = $("title").text();
name = name.substr(0, name.indexOf("_哔哩哔哩"));
const response = await axios({
method: 'get',
url: `https://api.bilibili.com/x/v2/reply?type=1&oid=${avid}&sort=0`,
headers: {
'User-Agent': config.ua,
'Referer': `https://www.bilibili.com/video/av${avid}`,
}
});
const data = response.data.data.replies;
ctx.body = art(path.resolve(__dirname, '../../views/rss.art'), {
title: `${name} 的 评论`,
link: `https://www.bilibili.com/video/av${avid}`,
description: `${name} 的 评论`,
lastBuildDate: new Date().toUTCString(),
item: data.map((item) => ({
title: `${item.member.uname} : ${item.content.message}`,
description: `#${item.floor}<br> ${item.member.uname} : ${item.content.message}`,
pubDate: new Date(item.ctime * 1000).toUTCString(),
link: `https://www.bilibili.com/video/av${avid}/#reply${item.rpid}`
})),
});
};