diff --git a/docs/multimedia.md b/docs/multimedia.md index 909e66dc3..ee2654374 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -924,6 +924,12 @@ pageClass: routes +## 法国国际广播电台 + +### 滚动新闻 + + + ## 高清电台 ### 最新电影 diff --git a/lib/v2/rfi/maintainer.js b/lib/v2/rfi/maintainer.js new file mode 100644 index 000000000..169cca9bc --- /dev/null +++ b/lib/v2/rfi/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news': ['nczitzk'], +}; diff --git a/lib/v2/rfi/news.js b/lib/v2/rfi/news.js new file mode 100644 index 000000000..d25a46fb8 --- /dev/null +++ b/lib/v2/rfi/news.js @@ -0,0 +1,49 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.rfi.fr'; + const currentUrl = `${rootUrl}/cn/滚动新闻`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = $('.article__title') + .toArray() + .map((item) => { + item = $(item); + + return { + title: item.text(), + link: `${rootUrl}${item.parent().parent().attr('href')}`, + pubDate: parseDate(item.prev().find('time').attr('datetime')), + }; + }); + + 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.description = content('.t-content__body').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: '滚动新闻 - 法国国际广播电台', + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/rfi/radar.js b/lib/v2/rfi/radar.js new file mode 100644 index 000000000..3e03c60a6 --- /dev/null +++ b/lib/v2/rfi/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'rfi.fr': { + _name: '法国国际广播电台', + '.': [ + { + title: '滚动新闻', + docs: 'https://docs.rsshub.app/multimedia.html#fa-guo-guo-ji-guang-bo-dian-tai-gun-dong-xin-wen', + source: ['/'], + target: '/rfi/news', + }, + ], + }, +}; diff --git a/lib/v2/rfi/router.js b/lib/v2/rfi/router.js new file mode 100644 index 000000000..69a5972f6 --- /dev/null +++ b/lib/v2/rfi/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/news', require('./news')); +};