diff --git a/docs/multimedia.md b/docs/multimedia.md index 0c4ee045f3..71a96265f2 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -274,7 +274,9 @@ BT 之家的域名会变更,本路由以 为默认 ::: -## CNTV 栏目 +## CNTV + +### 栏目 ::: tip 提示 @@ -283,7 +285,7 @@ BT 之家的域名会变更,本路由以 为默认 ::: - + 栏目 diff --git a/lib/router.js b/lib/router.js index b9da10952f..94fa06247d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3464,9 +3464,6 @@ router.get('/chinafile/:category?', lazyloadRouteHandler('./routes/chinafile/ind // 科技島讀 router.get('/daodu/:caty?', lazyloadRouteHandler('./routes/daodu/index')); -// CNTV -router.get('/cntv/:column', lazyloadRouteHandler('./routes/cntv/cntv')); - // Grand-Challenge router.get('/grandchallenge/user/:id', lazyloadRouteHandler('./routes/grandchallenge/user')); router.get('/grandchallenge/challenges', lazyloadRouteHandler('./routes/grandchallenge/challenges')); diff --git a/lib/routes/cntv/cntv.js b/lib/routes/cntv/cntv.js deleted file mode 100644 index 41fdb1bd70..0000000000 --- a/lib/routes/cntv/cntv.js +++ /dev/null @@ -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: `

${item.videoBrief}



在线观看: M3U8在线播放

`, - pubDate: new Date(item.videoProductiontime * 1).toUTCString(), - link: item.videoUrl, - category: item.videoTag.split(','), - })), - }; -}; diff --git a/lib/v2/cntv/column.js b/lib/v2/cntv/column.js new file mode 100644 index 0000000000..1dffca0180 --- /dev/null +++ b/lib/v2/cntv/column.js @@ -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, + })), + }; +}; diff --git a/lib/v2/cntv/maintainer.js b/lib/v2/cntv/maintainer.js new file mode 100644 index 0000000000..6d7179db51 --- /dev/null +++ b/lib/v2/cntv/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:column': ['WhoIsSure', 'Fatpandac'], +}; diff --git a/lib/v2/cntv/radar.js b/lib/v2/cntv/radar.js new file mode 100644 index 0000000000..680895025a --- /dev/null +++ b/lib/v2/cntv/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/cntv/router.js b/lib/v2/cntv/router.js new file mode 100644 index 0000000000..e4c0be1495 --- /dev/null +++ b/lib/v2/cntv/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:column', require('./column')); +}; diff --git a/lib/v2/cntv/templates/column.art b/lib/v2/cntv/templates/column.art new file mode 100644 index 0000000000..3b127ecb40 --- /dev/null +++ b/lib/v2/cntv/templates/column.art @@ -0,0 +1,4 @@ +

{{ item.brief }}

+

时长:{{ item.length }}

+

+

在线观看