feat(route): add 企鹅直播直播间开播 (#8345)

This commit is contained in:
Ethan Shen
2021-10-05 17:19:43 +08:00
committed by GitHub
parent 67542da7bf
commit adf321e1e0
5 changed files with 61 additions and 0 deletions

View File

@@ -62,6 +62,12 @@ pageClass: routes
<Route author="hoilc" example="/egameqq/room/497383565" path="/egameqq/room/:id" :paramsDesc="['直播间 id, 可在主播直播间页 URL 中找到']"/>
## 企鹅直播
### 直播间开播
<Route author="nczitzk" example="/qq/live/10012045" path="/qq/live/:id" :paramsDesc="['直播间 id, 可在主播直播间页 URL 中找到']"/>
## 战旗直播
### 直播间开播

36
lib/v2/qq/live.js Normal file
View File

@@ -0,0 +1,36 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const id = ctx.params.id;
const rootUrl = 'https://live.qq.com';
const currentUrl = `${rootUrl}/${id}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const data = response.data.match(/"is_live":(\d),"game_count".*"nickname":"(.*)","child_name".*"show_time":(\d+),"activity".*"room_name":"(.*)","user_chat_level"/);
const items =
data[1] === '1'
? [
{
author: data[2],
guid: data[3],
title: data[4],
pubDate: parseDate(data[3] * 1000),
link: currentUrl,
},
]
: [];
ctx.state.data = {
title: `${data[2]}直播间 - 企鹅直播`,
link: currentUrl,
item: items,
allowEmpty: true,
};
};

3
lib/v2/qq/maintainer.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
'/live/:id': ['nczitzk'],
};

13
lib/v2/qq/radar.js Normal file
View File

@@ -0,0 +1,13 @@
module.exports = {
'qq.com': {
_name: '腾讯网',
live: [
{
title: '企鹅直播',
docs: 'https://docs.rsshub.app/live.html#qi-e-zhi-bo-zhi-bo-jian-ti-xing',
source: ['/:id', '/'],
target: '/qq/live/:id',
},
],
},
};

3
lib/v2/qq/router.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/live/:id', require('./live'));
};