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')); +};