feat: add radiocn podcast (#2461)

* feat: add radiocn podcast

* feat: add radiocn podcast

* feat: add radiocn podcast

* Update radio.js


Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
Cloud
2019-06-24 22:44:08 +08:00
committed by DIYgod
co-authored by DIYgod
parent a9bfc46e44
commit 638e418b09
3 changed files with 58 additions and 0 deletions
+6
View File
@@ -311,3 +311,9 @@ pageClass: routes
### 影视
<Route author="DIYgod" example="/zimuzu/resource/37031" path="/zimuzu/resource/:id?" :paramsDesc="['影视 id,对应影视的 URL 中找到,为空时输出最近更新']" supportBT="1"/>
## 中国广播
### 电台节目
<Route author="kt286" example="/radio/2/520767" path="/radio/:channelname/:name" :paramsDesc="['频道ID, 可在对应专辑页面的 URL 中找到','节目ID,可在对应专辑页面的 URL 中找到']" supportPodcast="1"/>
+3
View File
@@ -1427,6 +1427,9 @@ router.get('/aiyanxishe/:id/:sort?', require('./routes/aiyanxishe/home'));
// 飞客茶馆优惠信息
router.get('/flyertea/preferential', require('./routes/flyertea/preferential'));
// 中国广播
router.get('/radio/:channelname/:name', require('./routes/radio/radio'));
// TOPYS
router.get('/topys/:category', require('./routes/topys/article'));
+49
View File
@@ -0,0 +1,49 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const channelname = ctx.params.channelname; // 专辑id
const name = ctx.params.name; // 专辑id
const api = `http://tacc.radio.cn/pcpages/searchs/livehistory?channelname=${channelname}&name=${name}&start=1&rows=20`;
const response = await got.get(api);
const playList = response.data.passprogram;
let title = '';
let itunes_category = '';
if (playList && playList.length > 0) {
const first = playList[0];
title = `${first.channel_name} ${first.name}`;
itunes_category = first.channel_name;
}
const items = playList.map((item) => {
const single = {
title: `${item.name} ${item.broadcast_date}`,
link: 'http://' + item.stream_domain1 + item.stream_url1,
description: `
<audio controls="controls">
<source src="http://${item.stream_domain1}${item.stream_url1}" type="audio/x-m4a">
<source src="http://${item.stream_domain2}${item.stream_url2}" type="audio/x-m4a">
<source src="http://${item.stream_domain3}${item.stream_url3}" type="audio/x-m4a">
</audio>
`,
pubDate: item.update_time,
guid: item.id,
itunes_item_image: 'http://www.radio.cn/pc-portal/image/logo01.jpg',
enclosure_url: 'http://' + item.stream_domain1 + item.stream_url1,
enclosure_length: item.resource_length,
enclosure_type: 'audio/x-m4a',
};
return single;
});
ctx.state.data = {
title: title,
link: `http://www.radio.cn/pc-portal/sanji/zhibo_2.html?channelname=${channelname}&name=${name}&title=radio`,
description: title,
image: 'http://www.radio.cn/pc-portal/image/logo01.jpg',
itunes_author: 'radio.cn',
itunes_category: itunes_category,
item: items,
};
};