diff --git a/docs/multimedia.md b/docs/multimedia.md index 89eac44e78..c0710fdced 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -1389,6 +1389,10 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性 +### 播客 + + + ## 优酷 ### 频道 diff --git a/lib/router.js b/lib/router.js index 0345a7a276..215e334d61 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3128,8 +3128,9 @@ router.get('/manxiaosi/book/:id', lazyloadRouteHandler('./routes/manxiaosi/book' // 吉林大学校内通知 router.get('/jlu/oa', lazyloadRouteHandler('./routes/universities/jlu/oa')); -// 小宇宙 -router.get('/xiaoyuzhou', lazyloadRouteHandler('./routes/xiaoyuzhou/pickup')); +// 小宇宙 migrated to v2 +// router.get('/xiaoyuzhou', lazyloadRouteHandler('./routes/xiaoyuzhou/pickup')); +// router.get('/xiaoyuzhou/podcast/:id', lazyloadRouteHandler('./routes/xiaoyuzhou/podcast')); // 合肥工业大学 router.get('/hfut/tzgg', lazyloadRouteHandler('./routes/universities/hfut/tzgg')); diff --git a/lib/v2/xiaoyuzhou/maintainer.js b/lib/v2/xiaoyuzhou/maintainer.js new file mode 100644 index 0000000000..29f8a385e2 --- /dev/null +++ b/lib/v2/xiaoyuzhou/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/': ['prnake', 'Maecenas'], + '/podcast/:id': ['hondajojo'], +}; diff --git a/lib/routes/xiaoyuzhou/pickup.js b/lib/v2/xiaoyuzhou/pickup.js similarity index 100% rename from lib/routes/xiaoyuzhou/pickup.js rename to lib/v2/xiaoyuzhou/pickup.js diff --git a/lib/v2/xiaoyuzhou/podcast.js b/lib/v2/xiaoyuzhou/podcast.js new file mode 100644 index 0000000000..a7c24b3a72 --- /dev/null +++ b/lib/v2/xiaoyuzhou/podcast.js @@ -0,0 +1,36 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const link = `https://www.xiaoyuzhoufm.com/podcast/${ctx.params.id}`; + const response = await got({ + method: 'get', + url: link, + }); + + const $ = cheerio.load(response.data); + + const page_data = JSON.parse($('#__NEXT_DATA__')[0].children[0].data); + + const episodes = page_data.props.pageProps.podcast.episodes.map((item) => ({ + title: item.title, + enclosure_url: item.enclosure.url, + enclosure_length: item.duration, + enclosure_type: 'audio/mpeg', + link: `https://www.xiaoyuzhoufm.com/episode/${item.eid}`, + pubDate: parseDate(item.pubDate), + description: item.shownotes, + itunes_item_image: item.image.smallPicUrl, + })); + + ctx.state.data = { + title: page_data.props.pageProps.podcast.title, + link: `https://www.xiaoyuzhoufm.com/podcast/${page_data.props.pageProps.podcast.pid}`, + itunes_author: page_data.props.pageProps.podcast.author, + itunes_category: '', + image: page_data.props.pageProps.podcast.image.smallPicUrl, + item: episodes, + description: page_data.props.pageProps.podcast.description, + }; +}; diff --git a/lib/v2/xiaoyuzhou/radar.js b/lib/v2/xiaoyuzhou/radar.js new file mode 100644 index 0000000000..5462093ba8 --- /dev/null +++ b/lib/v2/xiaoyuzhou/radar.js @@ -0,0 +1,19 @@ +module.exports = { + 'xiaoyuzhoufm.com': { + _name: '小宇宙', + '.': [ + { + title: '发现', + docs: 'https://docs.rsshub.app/multimedia.html#xiao-yu-zhou', + source: ['/'], + target: '/xiaoyuzhou', + }, + { + title: '播客', + docs: 'https://docs.rsshub.app/multimedia.html#xiao-yu-zhou', + source: ['/podcast/:id'], + target: '/xiaoyuzhou/podcast/:id', + }, + ], + }, +}; diff --git a/lib/v2/xiaoyuzhou/router.js b/lib/v2/xiaoyuzhou/router.js new file mode 100644 index 0000000000..1e6fef5a64 --- /dev/null +++ b/lib/v2/xiaoyuzhou/router.js @@ -0,0 +1,4 @@ +module.exports = (router) => { + router.get('/podcast/:id', require('./podcast')); + router.get('/', require('./pickup')); +};