feat: add cntv column (#6080)

Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
Who's Sure 2020-11-02 19:15:21 +08:00 committed by GitHub
parent 45b6be29bc
commit 8d98d1e307
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 3 deletions

View File

@ -63,6 +63,25 @@ pageClass: routes
:::
## CNTV 栏目
::: tip 提示
栏目 ID 查找示例:
打开栏目具体某一期页面F12 控制台输入`column_id`得到栏目 ID。
:::
<Route author="WhoIsSure" example="/cntv/TOPC1451528971114112" path="/cntv/:column" :paramsDesc="['栏目ID, 可在对应CNTV栏目页面找到']">
栏目
| 新闻联播 | 新闻周刊 | 天下足球 |
| -------------------- | -------------------- | -------------------- |
| TOPC1451528971114112 | TOPC1451559180488841 | TOPC1451551777876756 |
</Route>
## EZTV
::: tip 提示

View File

@ -3453,10 +3453,11 @@ router.get('/wsj/:lang/:category', require('./routes/wsj/index'));
// China File
router.get('/chinafile/:category?', require('./routes/chinafile/index'));
// Grand-Challenge-user
router.get('/grandchallenge/user/:id', require('./routes/grandchallenge/user'));
// CNTV
router.get('/cntv/:column', require('./routes/cntv/cntv'));
// Grand-Challenge-Challenges
// Grand-Challenge
router.get('/grandchallenge/user/:id', require('./routes/grandchallenge/user'));
router.get('/grandchallenge/challenges', require('./routes/grandchallenge/challenges'));
module.exports = router;

24
lib/routes/cntv/cntv.js Normal file
View File

@ -0,0 +1,24 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const id = ctx.params.column;
const response = await got({
method: 'get',
url: `http://api.cntv.cn/lanmu/videolistByColumnId?id=${id}&n=20&of=fdate&p=1&type=0&serviceId=tvcctv`,
});
const data = response.data.response.docs;
const name = data[0].videoTag.split(',')[0] || id;
ctx.state.data = {
title: `CNTV 栏目 - ${name}`,
description: `${name} 栏目的视频更新`,
item: data.map((item) => ({
title: item.videoTitle,
description: `<p>${item.videoBrief}</p><br><p><img src="${item.videoKeyFrameUrl}"></p><br><p>在线观看: <a href="https://www.m3u8play.com/?play=https://hls.cntv.baishancdnx.cn/asp/hls/main/0303000a/3/default/${item.videoSharedCode}/main.m3u8">M3U8在线播放</a></p>`,
pubDate: new Date(item.videoProductiontime * 1).toUTCString(),
link: item.videoUrl,
category: item.videoTag.split(','),
})),
};
};