feat(route): add cgtn podcast 中国环球电视网 - 播客 (#12128)

* feat(route): add cgtn podcast

* apply changes of review
This commit is contained in:
Hengyu
2023-03-17 01:23:38 -09:00
committed by GitHub
parent 3e0eb276f1
commit 7c8422f84e
5 changed files with 65 additions and 0 deletions
+11
View File
@@ -2489,6 +2489,17 @@ category 对应的关键词有
</Route>
## 中国环球电视网
### 播客
<Route author="5upernova-heng" example="/cgtn/podcast/ezfm/4" path="/cgtn/podcast/:category/:id" :paramsDesc="['类型名','播客 id']" radar=1>
> 类型名与播客 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)
</Route>
## 中国日报
### 英语点津
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/podcast/:category/:id': ['5upernova-heng'],
};
+35
View File
@@ -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),
};
};
+13
View File
@@ -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',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/podcast/:category/:id', require('./podcast.js'));
};