diff --git a/README.md b/README.md index 64598a59b..1c7e0433c 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 * 流行 * 用户(团队) * 关键词 +* 斗鱼 + * 房间开播 ## 参与我们 diff --git a/docs/README.md b/docs/README.md index 2b5e397d8..30fd12f64 100644 --- a/docs/README.md +++ b/docs/README.md @@ -846,3 +846,13 @@ key: 产品密钥 路由: `/dribbble/keyword/:keyword` 参数: keyword,想要订阅的关键词 + +## 斗鱼 + +### 房间开播 + +举例: [https://rsshub.app/douyu/room/24422](https://rsshub.app/douyu/room/24422) + +路由: `/douyu/room/:id` + +参数: id,房间 id,可在主播房间页 URL 中找到 diff --git a/router.js b/router.js index 95bed9db1..d09a78ed4 100644 --- a/router.js +++ b/router.js @@ -217,4 +217,7 @@ router.get('/dribbble/popular/:timeframe?', require('./routes/dribbble/popular') router.get('/dribbble/user/:name', require('./routes/dribbble/user')); router.get('/dribbble/keyword/:keyword', require('./routes/dribbble/keyword')); +// 斗鱼 +router.get('/douyu/room/:id', require('./routes/douyu/room')); + module.exports = router; diff --git a/routes/douyu/room.js b/routes/douyu/room.js new file mode 100644 index 000000000..77773a6e1 --- /dev/null +++ b/routes/douyu/room.js @@ -0,0 +1,30 @@ +const axios = require('../../utils/axios'); +const config = require('../../config'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const response = await axios({ + method: 'get', + url: `http://open.douyucdn.cn/api/RoomApi/room/${id}`, + headers: { + 'User-Agent': config.ua, + Referer: `https://www.douyu.com/${id}`, + }, + }); + + const data = response.data.data; + + ctx.state.data = { + title: `${data.owner_name}的斗鱼直播间`, + link: `https://www.douyu.com/${id}`, + item: [ + { + title: data.room_name, + pubDate: new Date(data.start_time).toUTCString(), + guid: data.start_time, + link: `https://www.douyu.com/${id}`, + }, + ], + }; +};