From 4cd0bd2082a73ef81cbf25d3701070cc785f03b0 Mon Sep 17 00:00:00 2001 From: nasvel Date: Fri, 23 Jun 2023 10:00:37 +0200 Subject: [PATCH] feat(route): add a new router for radio france (#12694) * add a new router for radio france * set podcast support to 0 * format code as to the convention * add radar.js & add new lines to the end of files * convert spaces to tabs * use art template for item description * remove podcast attribute * english docs * fix: RouteEn instead of Route * fix: ['content'] is better written in dot notation. * fix eslint errors --- docs/en/traditional-media.md | 10 ++++++++ docs/traditional-media.md | 10 ++++++++ lib/v2/radiofrance/geopolitique.js | 32 ++++++++++++++++++++++++ lib/v2/radiofrance/maintainer.js | 3 +++ lib/v2/radiofrance/radar.js | 13 ++++++++++ lib/v2/radiofrance/router.js | 3 +++ lib/v2/radiofrance/templates/article.art | 4 +++ 7 files changed, 75 insertions(+) create mode 100644 lib/v2/radiofrance/geopolitique.js create mode 100644 lib/v2/radiofrance/maintainer.js create mode 100644 lib/v2/radiofrance/radar.js create mode 100644 lib/v2/radiofrance/router.js create mode 100644 lib/v2/radiofrance/templates/article.art diff --git a/docs/en/traditional-media.md b/docs/en/traditional-media.md index 33f9b3234..f18468716 100644 --- a/docs/en/traditional-media.md +++ b/docs/en/traditional-media.md @@ -355,6 +355,16 @@ Only `s00017` is in English. +## Radio France + +### Géopolitique + + + +French podcast on the international politics. This feed provides a better reading experience (full text) for the 3 latest articles. + + + ## Radio Free Asia (RFA) ### News diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 5430478b3..49e9858d6 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -2706,3 +2706,13 @@ category 对应的关键词有 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | + +## 法国广播电台 + +### 地缘政治栏目 + + + +法广电台地缘政治栏目最新3篇文章全文抓取,提供比官方源更佳的阅读体验。 + + \ No newline at end of file diff --git a/lib/v2/radiofrance/geopolitique.js b/lib/v2/radiofrance/geopolitique.js new file mode 100644 index 000000000..dd01987d5 --- /dev/null +++ b/lib/v2/radiofrance/geopolitique.js @@ -0,0 +1,32 @@ +const path = require('path'); +const got = require('@/utils/got'); +const parser = require('@/utils/rss-parser'); +const { art } = require('@/utils/render'); + +module.exports = async (ctx) => { + const feed = await parser.parseURL('https://radiofrance-podcast.net/podcast09/rss_10009.xml'); + + const items = await Promise.all( + // only retrieve the full text for the first 3 items + feed.items.slice(0, 3) + .map((item) => + ctx.cache.tryGet(item.link, async () => { + const uri = item.link.slice(item.link.indexOf('/franceinter')); + const apiurl = 'https://www.radiofrance.fr/api/v2.1/path?value=' + encodeURIComponent(uri); + const { data } = await got(apiurl); + + delete item.content; + delete item.contentSnippet; + + item.description = art(path.join(__dirname, 'templates/article.art'), data.content); + return item; + }))); + + ctx.state.data = { + title: feed.title, + link: feed.link, + description: feed.description, + item: items, + language: feed.language, + }; +}; diff --git a/lib/v2/radiofrance/maintainer.js b/lib/v2/radiofrance/maintainer.js new file mode 100644 index 000000000..e4940a016 --- /dev/null +++ b/lib/v2/radiofrance/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/geopolitique': ['xdu'], +}; diff --git a/lib/v2/radiofrance/radar.js b/lib/v2/radiofrance/radar.js new file mode 100644 index 000000000..952ffea4e --- /dev/null +++ b/lib/v2/radiofrance/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'radiofrance.fr': { + _name: 'Radio France', + 'www': [ + { + title: 'Géopolitique', + docs: 'https://docs.rsshub.app/traditional-media.html#fa-guo-guang-bo-dian-tai', + source: ['/franceinter/podcasts/geopolitique', '/'], + target: '/radiofrance/geopolitique', + }, + ], + }, +}; diff --git a/lib/v2/radiofrance/router.js b/lib/v2/radiofrance/router.js new file mode 100644 index 000000000..6e5b7e376 --- /dev/null +++ b/lib/v2/radiofrance/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/geopolitique', require('./geopolitique')); +}; diff --git a/lib/v2/radiofrance/templates/article.art b/lib/v2/radiofrance/templates/article.art new file mode 100644 index 000000000..1cdfbfc66 --- /dev/null +++ b/lib/v2/radiofrance/templates/article.art @@ -0,0 +1,4 @@ +

{{ standFirst }}

+{{ each bodyJson }} +

{{ $value.children[0].value }}

+{{/each}}