diff --git a/docs/traditional-media.md b/docs/traditional-media.md index eef02620f..9e328372d 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -2489,6 +2489,17 @@ category 对应的关键词有 +## 中国环球电视网 + +### 播客 + + + +> 类型名与播客 id 可以在播客对应的 URL 中找到 +> 如 URL `https://radio.cgtn.com/podcast/column/ezfm/More-to-Read/4` ,其 `category` 为 `ezfm` ,`id` 为 `4`,对应的订阅路由为 [`/podcast/ezfm/4`](https://rsshub.app/podcast/ezfm/4) + + + ## 中国日报 ### 英语点津 diff --git a/lib/v2/cgtn/maintainer.js b/lib/v2/cgtn/maintainer.js new file mode 100644 index 000000000..6728fc531 --- /dev/null +++ b/lib/v2/cgtn/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/podcast/:category/:id': ['5upernova-heng'], +}; diff --git a/lib/v2/cgtn/podcast.js b/lib/v2/cgtn/podcast.js new file mode 100644 index 000000000..b7de95941 --- /dev/null +++ b/lib/v2/cgtn/podcast.js @@ -0,0 +1,35 @@ +const got = require('@/utils/got'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +async function getData(category, id) { + const url = `https://radio.cgtn.com/downapiRES/radio/v1/program/historyList/programId${id}_category${category}_page1.json`; + const response = await got(url); + return response.data; +} + +function combDate(date, time) { + // combine date and time, return a Date object + return timezone(parseDate(date + ' ' + time), +8); +} + +module.exports = async (ctx) => { + const { category, id } = ctx.params; + const categoryMap = { ezfm: 1, other: 5 }; + const data = await getData(categoryMap[category], id); + const items = data.data.map((item) => ({ + title: item.title, + pubDate: combDate(item.showDate, item.time.split(' ')[0]), + description: item.programSeries.content || item.detail, + itunes_item_image: item.programUrl, + itunes_duration: item.duration, + enclosure_url: item.mediaUrl, + enclosure_type: 'audio/mpeg', + })); + ctx.state.data = { + title: `中国环球电视网 CGTN Podcast - ${data.info}`, + link: 'https://www.cgtn.com/radio/', + item: items, + description: String(data.info), + }; +}; diff --git a/lib/v2/cgtn/radar.js b/lib/v2/cgtn/radar.js new file mode 100644 index 000000000..8c1adb549 --- /dev/null +++ b/lib/v2/cgtn/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'cgtn.com': { + _name: '中国环球电视网 CGTN', + '.': [ + { + title: '播客', + docs: 'https://docs.rsshub.app/traditional-media.html#zhong-guo-huan-qiu-dian-shi-wang', + source: ['/podcast/column/:category/*/:id'], + target: '/cgtn/podcast/:category/:id', + }, + ], + }, +}; diff --git a/lib/v2/cgtn/router.js b/lib/v2/cgtn/router.js new file mode 100644 index 000000000..db5fc3b4a --- /dev/null +++ b/lib/v2/cgtn/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/podcast/:category/:id', require('./podcast.js')); +};