Skip to content

Commit

Permalink
rss: add panda room
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed May 23, 2018
1 parent eea9294 commit 0201ee1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
* 用户(团队)
* 关键词
* 斗鱼
* 房间开播
* 直播间开播
* 熊猫直播
* 直播间开播下播

## 参与我们

Expand Down
14 changes: 12 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 中找到
3 changes: 3 additions & 0 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
38 changes: 38 additions & 0 deletions routes/panda/room.js
Original file line number Diff line number Diff line change
@@ -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: `<img referrerpolicy="no-referrer" src="${data.roominfo.pictures.img}">`,
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: `<img referrerpolicy="no-referrer" src="${data.roominfo.pictures.img}">`,
pubDate: new Date(parseInt(data.roominfo.end_time) * 1000).toUTCString(),
guid: data.roominfo.end_time,
link: `https://www.panda.tv/${id}`,
},
],
};
};

0 comments on commit 0201ee1

Please sign in to comment.