Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add heibaizhibo.com #6098

Merged
merged 5 commits into from
Nov 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/live.md
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
@@ -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 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,
};
};