增加B站直播搜索,直播分区订阅 (#110)
* resolve DIYgod/RSSHub#104 - 直播分区 - 直播关键字 * update for template * add guid for liveArea and liveSearch change rss Title and item title * change live search RSS title and link update readme * Change warning to one line
This commit is contained in:
parent
9923374031
commit
6529fe47a1
|
|
@ -25,6 +25,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
|||
- 视频评论
|
||||
- link 公告
|
||||
- 直播开播
|
||||
- 直播搜索
|
||||
- 直播分区
|
||||
- 微博
|
||||
- 博主
|
||||
- 关键词
|
||||
|
|
|
|||
|
|
@ -193,6 +193,28 @@ s
|
|||
|
||||
参数: roomID, 房间号 可在直播间 URL 中找到,长短号均可
|
||||
|
||||
### 直播搜索
|
||||
|
||||
举例: [https://rss.now.sh/bilibili/live/search/编程/online](https://rss.now.sh/bilibili/live/search/编程/online)
|
||||
|
||||
路由: `bilibili/live/search/:key/:order`
|
||||
|
||||
参数: key, 搜索关键字
|
||||
order ,排序方式 开播时间: live_time,人气:online
|
||||
|
||||
### 直播分区
|
||||
|
||||
::: warning 注意
|
||||
由于接口未提供开播时间,如果直播间未更换标题与分区,将只会出现一次.如果直播间更换分区与标题,将再出现一次
|
||||
:::
|
||||
|
||||
举例: [https://rss.now.sh/bilibili/live/area/143/online](https://rss.now.sh/bilibili/live/area/143/online)
|
||||
|
||||
路由: `bilibili/live/area/:areaID/:order`
|
||||
|
||||
参数: areaID , 分区ID 分区增删较多,可通过 [https://api.live.bilibili.com/room/v1/Area/getList](分区列表)查询
|
||||
order ,排序方式 开播时间: live_time,人气:online
|
||||
|
||||
## 微博
|
||||
|
||||
### 博主
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ 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'));
|
||||
router.get('/bilibili/live/search/:key/:order', require('./routes/bilibili/liveSearch'));
|
||||
router.get('/bilibili/live/area/:areaID/:order', require('./routes/bilibili/liveArea'));
|
||||
|
||||
|
||||
// // 微博
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
const axios = require('axios');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const areaID = ctx.params.areaID;
|
||||
const order = ctx.params.order;
|
||||
|
||||
let orderTitle = ``;
|
||||
switch (order) {
|
||||
case "live_time":
|
||||
orderTitle = `最新开播`;
|
||||
break;
|
||||
case "online":
|
||||
orderTitle = `人气直播`;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
const nameResponse = await axios({
|
||||
method: 'get',
|
||||
url: `https://api.live.bilibili.com/room/v1/Area/getList`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
'Referer': `https://link.bilibili.com/p/center/index`
|
||||
}
|
||||
});
|
||||
|
||||
let parentTitle = "";
|
||||
let parentID = "";
|
||||
let areaTitle = "";
|
||||
|
||||
|
||||
for (parentArea of nameResponse.data.data) {
|
||||
for (area of parentArea.list) {
|
||||
if (area.id === areaID) {
|
||||
parentTitle = parentArea.name;
|
||||
parentID = parentArea.id;
|
||||
areaTitle = area.name;
|
||||
cateID = area.cate_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://api.live.bilibili.com/room/v1/AmuseArea/getThirdPageData?area_id=${areaID}&sort_type=${order}&page_size=30&scrollTid=0&page_no=1`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
'Referer': `https://live.bilibili.com/pages/area/ent-all`
|
||||
}
|
||||
});
|
||||
const data = response.data.data.room_list;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `哔哩哔哩直播-${parentTitle}·${areaTitle}分区-${orderTitle}`,
|
||||
link: `https://live.bilibili.com/pages/area/ent-all#${parentID}/${areaID}`,
|
||||
description: `哔哩哔哩直播-${parentTitle}·${areaTitle}分区-${orderTitle}`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: data.map((item) => ({
|
||||
title: `${item.uname} ${item.title}`,
|
||||
description: `${item.uname} ${item.title}`,
|
||||
pubDate: new Date().toUTCString(),
|
||||
guid: `https://live.bilibili.com/${item.roomid} ${item.title}`,
|
||||
link: `https://live.bilibili.com/${item.roomid}`
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
const axios = require('axios');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const key = ctx.params.key;
|
||||
const order = ctx.params.order;
|
||||
|
||||
const urlEncodedKey = encodeURIComponent(key);
|
||||
let orderTitle = ``;
|
||||
|
||||
switch (order) {
|
||||
case "live_time":
|
||||
orderTitle = `最新开播`;
|
||||
break;
|
||||
case "online":
|
||||
orderTitle = `人气直播`;
|
||||
break;
|
||||
}
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://search.bilibili.com/api/search?search_type=live_room&keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
'Referer': `https://search.bilibili.com/live?keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1&search_type=live`
|
||||
}
|
||||
});
|
||||
const data = response.data.result;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `哔哩哔哩直播-${key}-${orderTitle}`,
|
||||
link: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1&search_type=live`,
|
||||
description: `哔哩哔哩直播-${key}-${orderTitle}`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: data.map((item) => ({
|
||||
title: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
|
||||
description: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
|
||||
pubDate: new Date(item.live_time.replace(' ', 'T') + "+08:00").toUTCString(),
|
||||
guid: `https://live.bilibili.com/${item.roomid} ${item.live_time}`,
|
||||
link: `https://live.bilibili.com/${item.roomid}`
|
||||
})),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue