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
Show file tree
Hide file tree
Changes from 2 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
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
28 changes: 28 additions & 0 deletions lib/routes/heibaizhibo/room.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 item =
Object.keys(liveInfo.data[0].live_info).length === 0 || liveInfo.data[0].live_info.startDate === ''
? []
: [
{
title: liveInfo.data[0].text,
author: liveInfo.data[0].anchorInfo.nickname,
link: response.url,
},
];

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: item,
allowEmpty: true,
};
};