From 0201ee122dd86de905f72044abb7501c66e5a1b3 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 23 May 2018 16:43:46 +0800 Subject: [PATCH] rss: add panda room --- README.md | 4 +++- docs/README.md | 14 ++++++++++++-- router.js | 3 +++ routes/panda/room.js | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 routes/panda/room.js diff --git a/README.md b/README.md index 1c7e0433c..0363a9705 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,9 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 * 用户(团队) * 关键词 * 斗鱼 - * 房间开播 + * 直播间开播 +* 熊猫直播 + * 直播间开播下播 ## 参与我们 diff --git a/docs/README.md b/docs/README.md index 30fd12f64..7666c8ed4 100644 --- a/docs/README.md +++ b/docs/README.md @@ -849,10 +849,20 @@ key: 产品密钥 ## 斗鱼 -### 房间开播 +### 直播间开播 举例: [https://rsshub.app/douyu/room/24422](https://rsshub.app/douyu/room/24422) 路由: `/douyu/room/:id` -参数: id,房间 id,可在主播房间页 URL 中找到 +参数: id,直播间 id,可在主播直播间页 URL 中找到 + +## 熊猫直播 + +### 直播间开播下播 + +举例: [https://rsshub.app/panda/room/10300](https://rsshub.app/panda/room/10300) + +路由: `/panda/room/:id` + +参数: id,直播间 id,可在主播直播间页 URL 中找到 diff --git a/router.js b/router.js index d09a78ed4..af571f84c 100644 --- a/router.js +++ b/router.js @@ -220,4 +220,7 @@ router.get('/dribbble/keyword/:keyword', require('./routes/dribbble/keyword')); // 斗鱼 router.get('/douyu/room/:id', require('./routes/douyu/room')); +// 熊猫直播 +router.get('/panda/room/:id', require('./routes/panda/room')); + module.exports = router; diff --git a/routes/panda/room.js b/routes/panda/room.js new file mode 100644 index 000000000..d10bfa566 --- /dev/null +++ b/routes/panda/room.js @@ -0,0 +1,38 @@ +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://www.panda.tv/api_room?roomid=${id}`, + headers: { + 'User-Agent': config.ua, + Referer: `https://www.panda.tv/${id}`, + }, + }); + + const data = response.data.data; + + ctx.state.data = { + title: `${data.hostinfo.name}的熊猫直播间`, + link: `https://www.panda.tv/${id}`, + item: [ + { + title: `开播: ${data.roominfo.name}`, + description: ``, + pubDate: new Date(parseInt(data.roominfo.start_time) * 1000).toUTCString(), + guid: data.roominfo.start_time, + link: `https://www.panda.tv/${id}`, + }, + { + title: `下播: ${data.roominfo.name}`, + description: ``, + pubDate: new Date(parseInt(data.roominfo.end_time) * 1000).toUTCString(), + guid: data.roominfo.end_time, + link: `https://www.panda.tv/${id}`, + }, + ], + }; +};