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
This commit is contained in:
nasvel 2023-06-23 10:00:37 +02:00 committed by GitHub
parent 48003a068c
commit 4cd0bd2082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 75 additions and 0 deletions

View File

@ -355,6 +355,16 @@ Only `s00017` is in English.
</RouteEn>
## Radio France
### Géopolitique
<RouteEn author="xdu" example="/radiofrance/geopolitique" path="/radiofrance/geopolitique">
French podcast on the international politics. This feed provides a better reading experience (full text) for the 3 latest articles.
</RouteEn>
## Radio Free Asia (RFA)
### News

View File

@ -2706,3 +2706,13 @@ category 对应的关键词有
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
</Route>
## 法国广播电台
### 地缘政治栏目
<Route author="xdu" example="/radiofrance/geopolitique" path="/radiofrance/geopolitique">
法广电台地缘政治栏目最新3篇文章全文抓取提供比官方源更佳的阅读体验。
</Route>

View File

@ -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,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/geopolitique': ['xdu'],
};

View File

@ -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',
},
],
},
};

View File

@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/geopolitique', require('./geopolitique'));
};

View File

@ -0,0 +1,4 @@
<p>{{ standFirst }}</p>
{{ each bodyJson }}
<p>{{ $value.children[0].value }}</p>
{{/each}}