From b77f9da4937fefe0e17ee0697da818720da1601f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=9C=E9=A2=A8?=
<46919443+nwindz@users.noreply.github.com>
Date: Fri, 13 Mar 2020 00:31:21 +0800
Subject: [PATCH] feat:add showroom live (#4226)
---
docs/live.md | 6 ++++++
lib/router.js | 3 +++
lib/routes/showroom/room.js | 31 +++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+)
create mode 100644 lib/routes/showroom/room.js
diff --git a/docs/live.md b/docs/live.md
index 302c2096a9..a4d2f8d8fd 100644
--- a/docs/live.md
+++ b/docs/live.md
@@ -10,6 +10,12 @@ pageClass: routes
+## SHOWROOM 直播
+
+### 直播间开播
+
+
+
## 哔哩哔哩直播
### 直播开播
diff --git a/lib/router.js b/lib/router.js
index 4d6b8d9567..a4c2c024da 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -246,6 +246,9 @@ router.get('/huya/live/:id', require('./routes/huya/live'));
// kingkong直播
router.get('/kingkong/room/:id', require('./routes/kingkong/room'));
+// SHOWROOM直播
+router.get('/showroom/room/:id', require('./routes/showroom/room'));
+
// v2ex
router.get('/v2ex/topics/:type', require('./routes/v2ex/topics'));
router.get('/v2ex/post/:postid', require('./routes/v2ex/post'));
diff --git a/lib/routes/showroom/room.js b/lib/routes/showroom/room.js
new file mode 100644
index 0000000000..42c9ea1bcc
--- /dev/null
+++ b/lib/routes/showroom/room.js
@@ -0,0 +1,31 @@
+const got = require('@/utils/got');
+
+module.exports = async (ctx) => {
+ const id = ctx.params.id;
+
+ const response = await got({
+ method: 'get',
+ url: `https://www.showroom-live.com/api/room/profile?room_id=${id}`,
+ });
+
+ const data = response.data;
+
+ let item;
+ if (data.is_onlive) {
+ item = [
+ {
+ title: `${data.room_name}`,
+ pubDate: new Date(data.current_live_started_at * 1000).toUTCString(),
+ guid: new Date(data.current_live_started_at * 1000).toUTCString(),
+ link: data.share_url_live,
+ },
+ ];
+ }
+
+ ctx.state.data = {
+ title: `${data.room_name}的SHOWROOM直播间`,
+ link: data.share_url_live,
+ item: item,
+ allowEmpty: true,
+ };
+};