mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
feat(route): add 故事FM播客 (#12494)
* feat(route): add 故事FM播客 * fix: wrong url
This commit is contained in:
@@ -1493,6 +1493,10 @@ JavDB 有多个备用域名,本路由默认使用永久域名 <https://javdb.c
|
||||
|
||||
<Route author="sanmmm" example="/storyfm/index" path="/storyfm/index"/>
|
||||
|
||||
### 播客
|
||||
|
||||
<Route author="nczitzk" example="/storyfm/episodes" path="/storyfm/episodes" supportPodcast="1"/>
|
||||
|
||||
## 开眼
|
||||
|
||||
### 每日精选
|
||||
|
||||
@@ -1925,7 +1925,7 @@ router.get('/ctfhub/search/:limit?/:form?/:class?/:title?', lazyloadRouteHandler
|
||||
router.get('/liwushuo/index', lazyloadRouteHandler('./routes/liwushuo/index.js'));
|
||||
|
||||
// 故事fm
|
||||
router.get('/storyfm/index', lazyloadRouteHandler('./routes/storyfm/index.js'));
|
||||
// router.get('/storyfm/index', lazyloadRouteHandler('./routes/storyfm/index.js'));
|
||||
|
||||
// 中国日报
|
||||
router.get('/chinadaily/english/:category', lazyloadRouteHandler('./routes/chinadaily/english.js'));
|
||||
|
||||
63
lib/v2/storyfm/episodes.js
Normal file
63
lib/v2/storyfm/episodes.js
Normal file
@@ -0,0 +1,63 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://storyfm.cn';
|
||||
const currentUrl = `${rootUrl}/episodes-list/`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('.e-ep')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const a = item.find('h2.e-ep__title a');
|
||||
|
||||
return {
|
||||
title: a.text(),
|
||||
link: a.attr('href'),
|
||||
pubDate: parseDate(item.find('.whitespace-nowrap').text()),
|
||||
enclosure_type: 'audio/mpeg',
|
||||
enclosure_url: item.find('audio source').attr('src'),
|
||||
itunes_item_image: item.find('.zoom-image-container-progression img').attr('src'),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.author = content('.rs-post__author').text().replace(/By/, '').trim();
|
||||
item.description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
audio: item.enclosure_url,
|
||||
description: content('.rs-post__content').html(),
|
||||
});
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '故事FM',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
itunes_author: '故事FM',
|
||||
image: $('.custom-logo-link img').attr('src'),
|
||||
};
|
||||
};
|
||||
4
lib/v2/storyfm/maintainer.js
Normal file
4
lib/v2/storyfm/maintainer.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
'/episodes': ['nczitzk'],
|
||||
'/index': ['sanmmm'],
|
||||
};
|
||||
19
lib/v2/storyfm/radar.js
Normal file
19
lib/v2/storyfm/radar.js
Normal file
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'storyfm.cn': {
|
||||
_name: '故事FM',
|
||||
'.': [
|
||||
{
|
||||
title: '首页',
|
||||
docs: 'https://docs.rsshub.app/multimedia.html#ge-shi-fm',
|
||||
source: ['/'],
|
||||
target: '/storyfm/index',
|
||||
},
|
||||
{
|
||||
title: '播客',
|
||||
docs: 'https://docs.rsshub.app/multimedia.html#ge-shi-fm',
|
||||
source: ['/episodes-list', '/'],
|
||||
target: '/storyfm/episodes',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
4
lib/v2/storyfm/router.js
Normal file
4
lib/v2/storyfm/router.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/episodes', require('./episodes'));
|
||||
router.get('/index', require('./index'));
|
||||
};
|
||||
6
lib/v2/storyfm/templates/description.art
Normal file
6
lib/v2/storyfm/templates/description.art
Normal file
@@ -0,0 +1,6 @@
|
||||
{{ if audio }}
|
||||
<audio controls>
|
||||
<source src="{{ audio }}">
|
||||
</audio>
|
||||
{{ /if }}
|
||||
{{@ description }}
|
||||
Reference in New Issue
Block a user