Skip to content

Commit

Permalink
feat: add heibaizhibo.com (#6098)
Browse files Browse the repository at this point in the history
  • Loading branch information
laampui authored Nov 8, 2020
1 parent 40b376b commit 2424a8e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/live.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 中找到']"/>

## 虎牙直播

### 直播间开播
Expand Down
3 changes: 3 additions & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
31 changes: 31 additions & 0 deletions lib/routes/heibaizhibo/room.js
Original file line number Diff line number Diff line change
@@ -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,
};
};

1 comment on commit 2424a8e

@vercel
Copy link

@vercel vercel bot commented on 2424a8e Nov 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.