mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 23:59:56 +08:00
fix(route): fix cntv cannot read property 'docs' of undefined and refactor to V2 (#9005)
* Fix(route): Cannot read property 'docs' of undefined and change to V2 * Fix(route): change property path of limit * Fix(route): add parseInt() * Fix(route): fix DeepScan issue
This commit is contained in:
@@ -274,7 +274,9 @@ BT 之家的域名会变更,本路由以 <https://www.btbtt20.com> 为默认
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## CNTV 栏目
|
## CNTV
|
||||||
|
|
||||||
|
### 栏目
|
||||||
|
|
||||||
::: tip 提示
|
::: tip 提示
|
||||||
|
|
||||||
@@ -283,7 +285,7 @@ BT 之家的域名会变更,本路由以 <https://www.btbtt20.com> 为默认
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
<Route author="WhoIsSure" example="/cntv/TOPC1451528971114112" path="/cntv/:column" :paramsDesc="['栏目ID, 可在对应CNTV栏目页面找到']">
|
<Route author="WhoIsSure Fatpandac" example="/cntv/TOPC1451528971114112" path="/cntv/:column" :paramsDesc="['栏目ID, 可在对应CNTV栏目页面找到']">
|
||||||
|
|
||||||
栏目
|
栏目
|
||||||
|
|
||||||
|
|||||||
@@ -3464,9 +3464,6 @@ router.get('/chinafile/:category?', lazyloadRouteHandler('./routes/chinafile/ind
|
|||||||
// 科技島讀
|
// 科技島讀
|
||||||
router.get('/daodu/:caty?', lazyloadRouteHandler('./routes/daodu/index'));
|
router.get('/daodu/:caty?', lazyloadRouteHandler('./routes/daodu/index'));
|
||||||
|
|
||||||
// CNTV
|
|
||||||
router.get('/cntv/:column', lazyloadRouteHandler('./routes/cntv/cntv'));
|
|
||||||
|
|
||||||
// Grand-Challenge
|
// Grand-Challenge
|
||||||
router.get('/grandchallenge/user/:id', lazyloadRouteHandler('./routes/grandchallenge/user'));
|
router.get('/grandchallenge/user/:id', lazyloadRouteHandler('./routes/grandchallenge/user'));
|
||||||
router.get('/grandchallenge/challenges', lazyloadRouteHandler('./routes/grandchallenge/challenges'));
|
router.get('/grandchallenge/challenges', lazyloadRouteHandler('./routes/grandchallenge/challenges'));
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
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(','),
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
29
lib/v2/cntv/column.js
Normal file
29
lib/v2/cntv/column.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const { art } = require('@/utils/render');
|
||||||
|
const path = require('path');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const id = ctx.params.column;
|
||||||
|
const limit = isNaN(parseInt(ctx.query.limit)) ? 25 : parseInt(ctx.query.limit);
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://api.cntv.cn/NewVideo/getVideoListByColumn?id=${id}&n=${limit}&sort=desc&p=1&mode=0&serviceId=tvcctv`,
|
||||||
|
});
|
||||||
|
const data = response.data.data.list;
|
||||||
|
const name = data[0].title.match(/《(.*?)》/)[1];
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `CNTV 栏目 - ${name}`,
|
||||||
|
description: `${name} 栏目的视频更新`,
|
||||||
|
item: data.map((item) => ({
|
||||||
|
title: item.title,
|
||||||
|
description: art(path.join(__dirname, 'templates/column.art'), {
|
||||||
|
item,
|
||||||
|
}),
|
||||||
|
pubDate: parseDate(item.time),
|
||||||
|
link: item.url,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/cntv/maintainer.js
Normal file
3
lib/v2/cntv/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/:column': ['WhoIsSure', 'Fatpandac'],
|
||||||
|
};
|
||||||
13
lib/v2/cntv/radar.js
Normal file
13
lib/v2/cntv/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'cctv.com': {
|
||||||
|
_name: 'CCTV',
|
||||||
|
navi: [
|
||||||
|
{
|
||||||
|
title: '栏目订阅',
|
||||||
|
docs: 'https://docs.rsshub.app/multimedia.html#cntv-lan-mu',
|
||||||
|
source: ['/'],
|
||||||
|
target: '/cntv/:column',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/cntv/router.js
Normal file
3
lib/v2/cntv/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function (router) {
|
||||||
|
router.get('/:column', require('./column'));
|
||||||
|
};
|
||||||
4
lib/v2/cntv/templates/column.art
Normal file
4
lib/v2/cntv/templates/column.art
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<p>{{ item.brief }}</p>
|
||||||
|
<p>时长:{{ item.length }}</p>
|
||||||
|
<p><img src="{{ item.image }}"></p>
|
||||||
|
<p><a href="{{ item.url }}">在线观看</a></p>
|
||||||
Reference in New Issue
Block a user