mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
add bilibili live room
This commit is contained in:
@@ -24,6 +24,7 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
||||
- 分区视频
|
||||
- 视频评论
|
||||
- link 公告
|
||||
- 直播开播
|
||||
- 微博
|
||||
- 博主
|
||||
- 网易云音乐
|
||||
|
||||
@@ -167,11 +167,19 @@ s
|
||||
|
||||
### link 公告
|
||||
|
||||
举例: https://rss.now.sh/bilibili/link/news/live
|
||||
举例: [https://rss.now.sh/bilibili/link/news/live](https://rss.now.sh/bilibili/link/news/live)
|
||||
|
||||
路由: `/bilibili/link/news/:product`
|
||||
|
||||
参数: product 公告分类 包括 直播:live 小视频:vc 相簿:wh
|
||||
参数: product, 公告分类 包括 直播:live 小视频:vc 相簿:wh
|
||||
|
||||
### 直播开播
|
||||
|
||||
举例: [https://rss.now.sh/bilibili/live/room/63489](https://rss.now.sh/bilibili/live/room/63489)
|
||||
|
||||
路由: `bilibili/live/room/:roomID`
|
||||
|
||||
参数: roomID, 房间号 可在直播间 URL 中找到,长短号均可
|
||||
|
||||
## 微博
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ router.get('/bilibili/partion/:tid', require('./routes/bilibili/partion'));
|
||||
router.get('/bilibili/bangumi/:seasonid', require('./routes/bilibili/bangumi'));
|
||||
router.get('/bilibili/video/reply/:aid', require('./routes/bilibili/reply'));
|
||||
router.get('/bilibili/link/news/:product', require('./routes/bilibili/linkNews'));
|
||||
router.get('/bilibili/live/room/:roomID', require('./routes/bilibili/liveRoom'));
|
||||
|
||||
|
||||
// // 微博
|
||||
|
||||
63
routes/bilibili/liveRoom.js
Normal file
63
routes/bilibili/liveRoom.js
Normal file
@@ -0,0 +1,63 @@
|
||||
const axios = require('axios');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let roomID = ctx.params.roomID;
|
||||
|
||||
//短号查询长号
|
||||
if (parseInt(roomID, 10) < 10000) {
|
||||
|
||||
const roomIDResponse = await axios({
|
||||
method: 'get',
|
||||
url: `https://api.live.bilibili.com/room/v1/Room/room_init?id=${roomID}`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
'Referer': `https://live.bilibili.com/${roomID}`
|
||||
}
|
||||
});
|
||||
roomID = roomIDResponse.data.data.room_id;
|
||||
}
|
||||
|
||||
const nameResponse = await axios({
|
||||
method: 'get',
|
||||
url: `https://api.live.bilibili.com/live_user/v1/UserInfo/get_anchor_in_room?roomid=${roomID}`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
'Referer': `https://live.bilibili.com/${roomID}`
|
||||
}
|
||||
});
|
||||
|
||||
const name = nameResponse.data.data.info.uname;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${roomID}&from=room`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
'Referer': `https://live.bilibili.com/${roomID}`
|
||||
}
|
||||
});
|
||||
const data = response.data.data;
|
||||
|
||||
let liveItem = [];
|
||||
|
||||
if (data.live_status === 1) {
|
||||
liveItem.push({
|
||||
title: data.title,
|
||||
description: `${ data.title}<br>${data.description}`,
|
||||
pubDate: new Date(data.live_time.replace(' ', 'T') + "+08:00").toUTCString(),
|
||||
guid: `https://live.bilibili.com/${roomID} ${data.live_time}`,
|
||||
link: `https://live.bilibili.com/${roomID}`
|
||||
});
|
||||
}
|
||||
|
||||
ctx.body = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: `${name} 直播间开播状态`,
|
||||
link: `https://live.bilibili.com/${roomID}`,
|
||||
description: `${name} 直播间开播了`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: liveItem,
|
||||
});
|
||||
};
|
||||
@@ -21,7 +21,7 @@
|
||||
<title><![CDATA[{{ $value.title }}]]></title>
|
||||
<description><![CDATA[{{@ $value.description || $value.title }}]]></description>
|
||||
{{ if $value.pubDate }}<pubDate>{{ $value.pubDate }}</pubDate>{{ /if }}
|
||||
<guid>{{ $value.link }}</guid>
|
||||
<guid>{{ $value.guid || $value.link }}</guid>
|
||||
<link>{{ $value.link }}</link>
|
||||
</item>
|
||||
{{ /each }}
|
||||
|
||||
Reference in New Issue
Block a user