From adf321e1e0da583c6eece28e40ab71498403a72c Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Tue, 5 Oct 2021 17:19:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=BC=81=E9=B9=85?= =?UTF-8?q?=E7=9B=B4=E6=92=AD=E7=9B=B4=E6=92=AD=E9=97=B4=E5=BC=80=E6=92=AD?= =?UTF-8?q?=20(#8345)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/live.md | 6 ++++++ lib/v2/qq/live.js | 36 ++++++++++++++++++++++++++++++++++++ lib/v2/qq/maintainer.js | 3 +++ lib/v2/qq/radar.js | 13 +++++++++++++ lib/v2/qq/router.js | 3 +++ 5 files changed, 61 insertions(+) create mode 100644 lib/v2/qq/live.js create mode 100644 lib/v2/qq/maintainer.js create mode 100644 lib/v2/qq/radar.js create mode 100644 lib/v2/qq/router.js diff --git a/docs/live.md b/docs/live.md index e92c8c05fb..024468cda5 100644 --- a/docs/live.md +++ b/docs/live.md @@ -62,6 +62,12 @@ pageClass: routes +## 企鹅直播 + +### 直播间开播 + + + ## 战旗直播 ### 直播间开播 diff --git a/lib/v2/qq/live.js b/lib/v2/qq/live.js new file mode 100644 index 0000000000..23a915e30a --- /dev/null +++ b/lib/v2/qq/live.js @@ -0,0 +1,36 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const rootUrl = 'https://live.qq.com'; + const currentUrl = `${rootUrl}/${id}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const data = response.data.match(/"is_live":(\d),"game_count".*"nickname":"(.*)","child_name".*"show_time":(\d+),"activity".*"room_name":"(.*)","user_chat_level"/); + + const items = + data[1] === '1' + ? [ + { + author: data[2], + guid: data[3], + title: data[4], + pubDate: parseDate(data[3] * 1000), + link: currentUrl, + }, + ] + : []; + + ctx.state.data = { + title: `${data[2]}直播间 - 企鹅直播`, + link: currentUrl, + item: items, + allowEmpty: true, + }; +}; diff --git a/lib/v2/qq/maintainer.js b/lib/v2/qq/maintainer.js new file mode 100644 index 0000000000..c424e80069 --- /dev/null +++ b/lib/v2/qq/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/live/:id': ['nczitzk'], +}; diff --git a/lib/v2/qq/radar.js b/lib/v2/qq/radar.js new file mode 100644 index 0000000000..6a0d8e3ee2 --- /dev/null +++ b/lib/v2/qq/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'qq.com': { + _name: '腾讯网', + live: [ + { + title: '企鹅直播', + docs: 'https://docs.rsshub.app/live.html#qi-e-zhi-bo-zhi-bo-jian-ti-xing', + source: ['/:id', '/'], + target: '/qq/live/:id', + }, + ], + }, +}; diff --git a/lib/v2/qq/router.js b/lib/v2/qq/router.js new file mode 100644 index 0000000000..3f0bbeea47 --- /dev/null +++ b/lib/v2/qq/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/live/:id', require('./live')); +};