diff --git a/docs/en/traditional-media.md b/docs/en/traditional-media.md index c352e0f6b..d148b1e9c 100644 --- a/docs/en/traditional-media.md +++ b/docs/en/traditional-media.md @@ -221,6 +221,8 @@ Only `s00017` is in English. ## Radio Free Asia (RFA) +### News + Delivers a better experience by supporting parameter specification. diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 47e1eae35..96863728e 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -1663,6 +1663,8 @@ category 对应的关键词有 ## 自由亚洲电台 +### 新闻 + 通过指定频道参数,提供比官方源更佳的阅读体验。 diff --git a/lib/router.js b/lib/router.js index 21f540ba0..97daf3bfc 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3732,9 +3732,6 @@ router.get('/simpread/notice', lazyloadRouteHandler('./routes/simpread/notice')) // SimpRead-更新日志 router.get('/simpread/changelog', lazyloadRouteHandler('./routes/simpread/changelog')); -// Radio Free Asia -router.get('/rfa/:language?/:channel?/:subChannel?', lazyloadRouteHandler('./routes/rfa/index')); - // booth.pm router.get('/booth.pm/shop/:subdomain', lazyloadRouteHandler('./routes/booth-pm/shop')); diff --git a/lib/routes/rfa/index.js b/lib/v2/rfa/index.js similarity index 53% rename from lib/routes/rfa/index.js rename to lib/v2/rfa/index.js index f1e003cdf..191e11f9e 100644 --- a/lib/routes/rfa/index.js +++ b/lib/v2/rfa/index.js @@ -1,8 +1,9 @@ const cheerio = require('cheerio'); const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { - let url = 'https://www.rfa.org/' + (ctx.params.language || 'english'); + let url = 'https://www.rfa.org/' + (ctx.params.language ?? 'english'); if (ctx.params.channel) { url += '/' + ctx.params.channel; @@ -11,10 +12,10 @@ module.exports = async (ctx) => { url += '/' + ctx.params.subChannel; } - const response = await got.get(url); + const response = await got(url); const $ = cheerio.load(response.data); - const selectors = ['div[id=topstorywidefulltease]', 'div.two_featured', 'div.three_featured', 'div.single_column_teaser', 'div.sectionteaser', 'div.specialwrap']; + const selectors = ['div[id=topstorywidefull]', 'div.two_featured', 'div.three_featured', 'div.single_column_teaser', 'div.sectionteaser', 'div.specialwrap']; const list = []; selectors.forEach((selector) => { $(selector).each((_, e) => { @@ -28,11 +29,15 @@ module.exports = async (ctx) => { const result = await Promise.all( list.map((item) => ctx.cache.tryGet(item.link, async () => { - const content = await got.get(item.link); + const content = await got(item.link); const description = cheerio.load(content.data); - item.description = description('div[id=storytext]').html(); - item.pubDate = new Date(description('span[id=story_date]').text()).toUTCString(); + item.description = description('#headerimg').html() + description('div[id=storytext]').html(); + item.pubDate = parseDate(description('span[id=story_date]').text()); + if (description('meta[property=og:audio]').attr('content') !== undefined) { + item.enclosure_url = description('meta[property=og:audio]').attr('content'); + item.enclosure_type = description('meta[property=og:audio:type]').attr('content'); + } return item; }) ) diff --git a/lib/v2/rfa/maintainer.js b/lib/v2/rfa/maintainer.js new file mode 100644 index 000000000..4fc521de2 --- /dev/null +++ b/lib/v2/rfa/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:language?/:channel?/:subChannel?': ['zphw'], +}; diff --git a/lib/v2/rfa/radar.js b/lib/v2/rfa/radar.js new file mode 100644 index 000000000..c5fae2e47 --- /dev/null +++ b/lib/v2/rfa/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'rfa.org': { + _name: '自由亚洲电台', + '.': [ + { + title: '新闻', + docs: 'https://docs.rsshub.app/traditional-media.html#zi-you-ya-zhou-dian-tai', + source: '/:language/:channel/:subChannel', + target: '/rfa/:language/:channel/:subChannel', + }, + ], + }, +}; diff --git a/lib/v2/rfa/router.js b/lib/v2/rfa/router.js new file mode 100644 index 000000000..567c98a14 --- /dev/null +++ b/lib/v2/rfa/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:language?/:channel?/:subChannel?', require('./index')); +};