Fix bangumi eps date (#942) & 虎牙直播

This commit is contained in:
SettingDust
2018-10-24 00:15:57 +08:00
committed by DIYgod
parent 3ad21f5683
commit 6371e82fc0
5 changed files with 40 additions and 2 deletions

1
.gitignore vendored
View File

@@ -13,3 +13,4 @@ yarn-error.log
tmp
newrelic_agent.log
*.swp
*.iml

View File

@@ -686,6 +686,10 @@ GitHub 官方也提供了一些 RSS:
<route name="直播间开播下播" author="DIYgod" example="/panda/room/10300" path="/panda/room/:id" :paramsDesc="['直播间 id, 可在主播直播间页 URL 中找到']"/>
### 虎牙直播
<route name="直播间开播" author="SettingDust" example="/huya/live/edmunddzhang" path="/huya/live/:id" :paramsDesc="['直播间id或主播名(有一些id是名字如上)']"/>
## 音视频
### bilibili

View File

@@ -265,6 +265,9 @@ router.get('/douyu/room/:id', require('./routes/douyu/room'));
// 熊猫直播
router.get('/panda/room/:id', require('./routes/panda/room'));
// 虎牙
router.get('/huya/live/:id', require('./routes/huya/live'));
// v2ex
router.get('/v2ex/topics/:type', require('./routes/v2ex/topics'));

View File

@@ -1,5 +1,4 @@
const axios = require('../../../utils/axios');
const DateTime = require('luxon').DateTime;
module.exports = async (subjectID) => {
const url = `https://api.bgm.tv/subject/${subjectID}?responseGroup=large`;
@@ -19,7 +18,7 @@ module.exports = async (subjectID) => {
item: activeEps.reverse().map((e) => ({
title: `ep.${e.sort} ${e.name_cn}`,
description: `<img src="${epsInfo.images.common}" alt="ep.${e.sort} ${e.name_cn}"><p>${e.desc.replace(/\n+/g, '<br>')}</p>`,
pubDate: DateTime.fromFormat(e.airdate, 'yyyy-L-dd'),
pubDate: new Date(e.airdate).toUTCString(),
guid: e.id,
link: e.url,
})),

31
routes/huya/live.js Normal file
View File

@@ -0,0 +1,31 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const id = ctx.params.id;
const url = `https://search.cdn.huya.com/?m=Search&do=getSearchContent&q=${id}&typ=-5&rows=1`;
const response = await axios({
method: 'get',
url: url,
});
const data = response.data.response['1'].docs[0];
let items = [];
if (data.gameLiveOn) {
items = [
{
title: `${data.live_intro}`,
pubDate: new Date(data.rec_live_time).toUTCString(),
guid: data.uid,
link: url,
image: data.game_avatarUrl180,
},
];
}
ctx.state.data = {
title: `${data.game_nick}的虎牙直播`,
link: url,
item: items,
};
};