From eb3ac73f427eb79877e13a203d7c3f4dc443d806 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Wed, 4 Nov 2020 20:07:20 +0800 Subject: [PATCH 1/5] feat: add heibaizhibo.com --- docs/live.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/heibaizhibo/room.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 lib/routes/heibaizhibo/room.js diff --git a/docs/live.md b/docs/live.md index 137deefb7dd07c..3d056c7a33dc17 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 1b029baef73eb6..27ecb953ee854a 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 00000000000000..350087354500e9 --- /dev/null +++ b/lib/routes/heibaizhibo/room.js @@ -0,0 +1,30 @@ +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 = + liveInfo.data[0].live_info.startDate.length === 0 + ? [] + : [ + { + title: liveInfo.data[0].text, + author: liveInfo.data[0].anchorInfo.nickname, + pubDate: new Date(liveInfo.data[0].live_info.startDate), + url: response.url, + guid: id + 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: item, + allowEmpty: true, + }; +}; From cfb21d7ed3aeccc15d2a74de597055c1fd7d9306 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Thu, 5 Nov 2020 08:24:49 +0800 Subject: [PATCH 2/5] fix: heibaizhibo live status --- lib/routes/heibaizhibo/room.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/routes/heibaizhibo/room.js b/lib/routes/heibaizhibo/room.js index 350087354500e9..a6dade076caebb 100644 --- a/lib/routes/heibaizhibo/room.js +++ b/lib/routes/heibaizhibo/room.js @@ -7,15 +7,13 @@ module.exports = async (ctx) => { const liveInfo = Function('const window={};' + response.data.match(/window\.__NUXT__=.*;/gm)[0] + 'return window.__NUXT__')(); const item = - liveInfo.data[0].live_info.startDate.length === 0 + 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, - pubDate: new Date(liveInfo.data[0].live_info.startDate), - url: response.url, - guid: id + liveInfo.data[0].live_info.startDate, + link: response.url, }, ]; From cd47f92f31831a81198884a99fbbdf6d37e97c95 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Thu, 5 Nov 2020 18:12:20 +0800 Subject: [PATCH 3/5] fix: update detect --- lib/routes/heibaizhibo/room.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/routes/heibaizhibo/room.js b/lib/routes/heibaizhibo/room.js index a6dade076caebb..1835d7b92842bc 100644 --- a/lib/routes/heibaizhibo/room.js +++ b/lib/routes/heibaizhibo/room.js @@ -14,6 +14,7 @@ module.exports = async (ctx) => { title: liveInfo.data[0].text, author: liveInfo.data[0].anchorInfo.nickname, link: response.url, + guid: response.url + liveInfo.data[0].live_info.startDate, }, ]; From b611d0b1c52249de125f65911b797009e9ea3ec0 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Sat, 7 Nov 2020 17:32:09 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=E9=BB=91=E7=99=BD=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/heibaizhibo/room.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/routes/heibaizhibo/room.js b/lib/routes/heibaizhibo/room.js index 1835d7b92842bc..eb3f0c06bc7052 100644 --- a/lib/routes/heibaizhibo/room.js +++ b/lib/routes/heibaizhibo/room.js @@ -5,18 +5,20 @@ module.exports = async (ctx) => { 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 = - 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, - guid: response.url + liveInfo.data[0].live_info.startDate, - }, - ]; + 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} - 黑白直播`, From 0382a8f9cd2c6a957026ae917847b0219d6a15b4 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Sun, 8 Nov 2020 01:26:08 +0000 Subject: [PATCH 5/5] Update room.js --- lib/routes/heibaizhibo/room.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/routes/heibaizhibo/room.js b/lib/routes/heibaizhibo/room.js index eb3f0c06bc7052..970374fde3318a 100644 --- a/lib/routes/heibaizhibo/room.js +++ b/lib/routes/heibaizhibo/room.js @@ -25,7 +25,7 @@ module.exports = async (ctx) => { image: liveInfo.data[0].anchorInfo.portrait, description: liveInfo.data[0].anchorInfo.notice, link: response.url, - item: item, + item, allowEmpty: true, }; };