feat: add 战旗直播支持 (#3215)
This commit is contained in:
@@ -43,3 +43,9 @@ pageClass: routes
|
||||
### 直播间开播
|
||||
|
||||
<Route author="SettingDust xyqfer" example="/huya/live/edmunddzhang" path="/huya/live/:id" :paramsDesc="['直播间id或主播名(有一些id是名字,如上)']"/>
|
||||
|
||||
## 战旗直播
|
||||
|
||||
### 直播间开播
|
||||
|
||||
<Route author="cssxsh" example="/zhanqi/room/anime" path="/zhanqi/room/:id" :paramsDesc="['直播间 id, 可在主播直播间页 URL 中找到']"/>
|
||||
|
||||
@@ -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'));
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user