feat: add heibaizhibo.com (#6098)

This commit is contained in:
Laam Pui
2020-11-08 01:26:22 +00:00
committed by GitHub
parent 40b376b721
commit 2424a8e5a1
3 changed files with 40 additions and 0 deletions
+6
View File
@@ -38,6 +38,12 @@ pageClass: routes
<Route author="DIYgod" example="/douyu/room/24422" path="/douyu/room/:id" :paramsDesc="['直播间 id, 可在主播直播间页 URL 中找到']"/>
## 黑白直播
### 直播间开播
<Route author="laampui" example="/heibaizhibo/room/195976" path="/heibaizhibo/room/:id" :paramsDesc="['直播间 id, 可在主播直播间页 URL 中找到']"/>
## 虎牙直播
### 直播间开播
+3
View File
@@ -3123,6 +3123,9 @@ router.get('/touhougarakuta/:language/:type', require('./routes/touhougarakuta')
// 猎趣TV
router.get('/liequtv/room/:id', require('./routes/liequtv/room'));
// 黑白直播
router.get('/heibaizhibo/room/:id', require('./routes/heibaizhibo/room'));
// Behance
router.get('/behance/:user/:type?', require('./routes/behance/index'));
+31
View File
@@ -0,0 +1,31 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const id = ctx.params.id;
const response = await got.get(`https://www.heibaizhibo.com/anchorLive/${id}`);
const liveInfo = Function('const window={};' + response.data.match(/window\.__NUXT__=.*;/gm)[0] + 'return window.__NUXT__')();
const gtvId = liveInfo.data[0].gtvId;
const res = await got.get(`https://sig.heibaizhibo.com/signal-front/live/matchLiveInfo?gtvId=${gtvId}&source=2&liveType=3&defi=hd`);
const offline = res.data.data[0].score === -1;
const item = offline
? []
: [
{
title: liveInfo.data[0].text,
author: liveInfo.data[0].anchorInfo.nickname,
link: response.url,
guid: response.url + liveInfo.data[0].live_info.startDate,
},
];
ctx.state.data = {
title: `${liveInfo.data[0].anchorInfo.nickname} - 黑白直播`,
image: liveInfo.data[0].anchorInfo.portrait,
description: liveInfo.data[0].anchorInfo.notice,
link: response.url,
item,
allowEmpty: true,
};
};