diff --git a/docs/live.md b/docs/live.md index 137deefb7d..3d056c7a33 100644 --- a/docs/live.md +++ b/docs/live.md @@ -38,6 +38,12 @@ pageClass: routes +## 黑白直播 + +### 直播间开播 + + + ## 虎牙直播 ### 直播间开播 diff --git a/lib/router.js b/lib/router.js index b19d5586b6..868569d665 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/heibaizhibo/room.js b/lib/routes/heibaizhibo/room.js new file mode 100644 index 0000000000..970374fde3 --- /dev/null +++ b/lib/routes/heibaizhibo/room.js @@ -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, + }; +};