diff --git a/docs/multimedia.md b/docs/multimedia.md index 2f96f22836..dcb8df5956 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -311,3 +311,9 @@ pageClass: routes ### 影视 + +## 中国广播 + +### 电台节目 + + diff --git a/lib/router.js b/lib/router.js index 6180847be0..ee0b458d48 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/radio/radio.js b/lib/routes/radio/radio.js new file mode 100644 index 0000000000..a2906174c2 --- /dev/null +++ b/lib/routes/radio/radio.js @@ -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: ` + + `, + 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, + }; +};