feat(route): add 云听 (#9665)

* feat(route): add 云听

* fix typo

* fix: wrong data
This commit is contained in:
Ethan Shen 2022-05-01 06:13:57 +08:00 committed by GitHub
parent 616ad78c88
commit e5484a75bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 79 additions and 7 deletions

View File

@ -1461,6 +1461,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
<Route author="xyqfer Fatpandac" example="/youku/channel/UNTg3MTM3OTcy" path="/youku/channel/:channelId/:embed?" :paramsDesc="['频道 id', '默认为开启内嵌视频, 任意值为关闭']"/>
## 云听
### 电台节目
<Route author="kt286 nczitzk" example="/radio/1552135" path="/radio/:id" :paramsDesc="['节目ID可在对应专辑页面的 URL 中找到']" supportPodcast="1"/>
## 中国高清网
### 电影
@ -1471,12 +1477,6 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
| -- | ------ | ----- | ---- | -- | ------ |
| 留空 | bluray | 1080p | 720p | 3d | webdl |
## 中国广播
### 电台节目
<Route author="kt286" example="/radio/2/520767" path="/radio/:channelname/:name" :paramsDesc="['频道ID, 可在对应专辑页面的 URL 中找到','节目ID可在对应专辑页面的 URL 中找到']" supportPodcast="1"/>
## 注视影视
### 更新通知

View File

@ -1758,7 +1758,7 @@ router.get('/huodongxing/explore', lazyloadRouteHandler('./routes/hdx/explore'))
// router.get('/flyertea/creditcard/:bank', lazyloadRouteHandler('./routes/flyert/creditcard'));
// 中国广播
router.get('/radio/:channelname/:name', lazyloadRouteHandler('./routes/radio/radio'));
// router.get('/radio/:channelname/:name', lazyloadRouteHandler('./routes/radio/radio'));
// TOPYS
// router.get('/topys/:category', lazyloadRouteHandler('./routes/topys/article'));

48
lib/v2/radio/index.js Normal file
View File

@ -0,0 +1,48 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const id = ctx.params.id;
const rootUrl = 'http://www.radio.cn';
const currentUrl = `${rootUrl}/pc-portal/sanji/detail.html?columnId=${id}`;
const apiRootUrl = 'http://tacc.radio.cn';
const apiUrl = `${apiRootUrl}/pcpages/odchannelpages?od_id=${id}&start=1&rows=50`;
const response = await got({
method: 'get',
url: apiUrl,
});
if (/^\(.*\)$/.test(response.data)) {
response.data = JSON.parse(response.data)[0];
}
const data = response.data.data;
const items = data.program.map((item) => ({
guid: item.id,
title: item.name,
link: item.streams[0].url,
description: `${item.description}${art(path.join(__dirname, 'templates/description.art'), {
streams: item.streams,
})}`,
pubDate: parseDate(item.onlinetime),
enclosure_url: item.streams[0].url,
enclosure_type: 'audio/x-m4a',
itunes_duration: item.duration,
itunes_item_image: data.odchannel.imageUrl[0].url,
}));
ctx.state.data = {
title: `云听 - ${data.odchannel.name}`,
link: currentUrl,
item: items,
image: data.odchannel.imageUrl[0].url,
itunes_author: data.odchannel.commissioningEditorName || data.odchannel.editorName || data.odchannel.source || 'radio.cn',
description: data.odchannel.description || data.odchannel.sub_title || '',
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/:id': ['kt286', 'nczitzk'],
};

13
lib/v2/radio/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'radio.cn': {
_name: '云听',
'.': [
{
title: '电台节目',
docs: 'https://docs.rsshub.app/multimedia.html#yun-ting-dian-tai-jie-mu',
source: ['/pc-portal/sanji/detail.html', '/'],
target: (params, url) => `/radio/${new URL(url).searchParams.get('columnId')}`,
},
],
},
};

3
lib/v2/radio/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:id', require('./index'));
};

View File

@ -0,0 +1,5 @@
<audio controls="controls">
{{each streams stream}}
<source src="{{ stream.url }}" type="audio/x-m4a">
{{/each}}
</audio>