From ff7caf3dd7d3f1303dc187627616781f0c469fde Mon Sep 17 00:00:00 2001
From: cssxsh <32539286+cssxsh@users.noreply.github.com>
Date: Fri, 18 Oct 2019 12:12:38 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E6=88=98=E6=97=97=E7=9B=B4?=
=?UTF-8?q?=E6=92=AD=E6=94=AF=E6=8C=81=20(#3215)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/live.md | 6 ++++++
lib/router.js | 3 +++
lib/routes/zhanqi/room.js | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+)
create mode 100644 lib/routes/zhanqi/room.js
diff --git a/docs/live.md b/docs/live.md
index 4f95237e7..302c2096a 100644
--- a/docs/live.md
+++ b/docs/live.md
@@ -43,3 +43,9 @@ pageClass: routes
### 直播间开播
+
+## 战旗直播
+
+### 直播间开播
+
+
diff --git a/lib/router.js b/lib/router.js
index 8dc7cd7ba..71d493feb 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -1822,6 +1822,9 @@ router.get('/watchface/:watch_type?/:list_type?', require('./routes/watchface/up
router.get('/cnu/selected', require('./routes/cnu/selected'));
router.get('/cnu/discovery/:type?/:category?', require('./routes/cnu/discovery'));
+// 战旗直播
+router.get('/zhanqi/room/:id', require('./routes/zhanqi/room'));
+
// 酒云网
router.get('/wineyun/:category', require('./routes/wineyun'));
diff --git a/lib/routes/zhanqi/room.js b/lib/routes/zhanqi/room.js
new file mode 100644
index 000000000..206733c73
--- /dev/null
+++ b/lib/routes/zhanqi/room.js
@@ -0,0 +1,37 @@
+const got = require('@/utils/got');
+
+module.exports = async (ctx) => {
+ const id = ctx.params.id;
+ const regexp = /(?<=window.oPageConfig.oRoom\s*=\s*)\{.*\}/;
+
+ const response = await got({
+ method: 'get',
+ url: `https://www.zhanqi.tv/${id}`,
+ });
+
+ const html = response.data;
+ const strArr = html.split('\n');
+ const str = strArr.find((str) => regexp.test(str));
+ // console.log(str.match(regexp)[0]);
+ const room = JSON.parse(str.match(regexp)[0]);
+
+ let item;
+ if (room.status !== '0') {
+ item = [
+ {
+ title: `开播: ${room.title}`,
+ // unix时间戳
+ pubDate: new Date(room.liveTime * 1000).toUTCString(),
+ guid: room.liveTime,
+ link: `https://www.zhanqi.tv${room.url}`,
+ description: room.roomDesc,
+ },
+ ];
+ }
+ ctx.state.data = {
+ title: `${room.nickname}的战旗直播间`,
+ link: `https://www.zhanqi.tv${room.url}`,
+ item: item,
+ allowEmpty: true,
+ };
+};