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, + }; +};