Replace BEA official feed with custom feed, close #64

This commit is contained in:
Lucidiot 2021-03-18 14:03:31 +01:00
parent b94c949906
commit fb6da3efc0
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
2 changed files with 67 additions and 10 deletions

View File

@ -64,16 +64,6 @@
</feed>
</source>
<source id="bea">
<name>Bureau d'Enquêtes et Analyses</name>
<region>France</region>
<type>Aviation</type>
<frequency>100 reports/year</frequency>
<feed lang="French" format="rss" id="bea-rss">
<link>https://www.bea.aero/no_cache/?type=100</link>
</feed>
</source>
<source id="beatt">
<name>Bureau d'Enquêtes sur les Accidents de Transport Terrestre</name>
<region>France</region>
@ -265,6 +255,25 @@
</feed>
</source>
<source id="bea">
<name>Bureau d'Enquêtes et Analyses</name>
<description><![CDATA[
The BEA used to provide its own official RSS feed, but decided to remove it to make their site "simpler"; I made it a point to make my own feed with as much data as I could get from their site.
]]></description>
<region>France</region>
<type>Aviation</type>
<frequency>100 reports/year</frequency>
<feed lang="French" format="rss" id="bea-rss">
<curl>
<url>https://bea.aero/les-enquetes/evenements-notifies/?tx_news_pi1[action]=searchResult&amp;tx_news_pi1[controller]=News&amp;tx_news_pi1[facetAction]=add&amp;tx_news_pi1[facetTitle]=etat_intS&amp;tx_news_pi1[facetValue]=100&amp;cHash=b4645da2a30ec0c83f60069d018b5619</url>
</curl>
<pup>article.search-entry</pup>
<jq path="bea.jq" />
<json2xml />
<output>bea.xml</output>
</feed>
</source>
<source id="jtsb">
<name>Japan Transport Safety Board</name>
<region>Japan</region>

48
jq/bea.jq Normal file
View File

@ -0,0 +1,48 @@
# BEA feed generator
# Expects pup JSON output holding <article> tags, outputs xmltodict-compatible JSON
# WARNING: Dates are locale-sensitive; the RSS feed might not generate correctly with another locale.
import "./helpers" as helpers;
{
"rss": {
"@version": "2.0",
"@xmlns": {
"georss": "http://www.georss.org/georss"
},
"channel": {
"title": "BEA",
"description": "Rapports d'enquête publiés par le Bureau d'Enquêtes et Analyses",
"link": "https://bea.aero",
"language": "fr-FR",
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://www.rssboard.org/rss-specification",
"ttl": 1440,
"generator": "ITSB",
"item": [
.[]
| . as $item
| {
"title": (.children[1].children[1].title | gsub("&#39;"; "'")),
"description": (
[
.children[0].children[1].children[].children
| .[0].text + " : " + ((.[1].children[0] | .text // .children[0].text) // .[1].text)
| gsub("&#39;"; "'")
]
| join("</li><li>")
| "<ul><li>\(.)</li></ul>"
),
"link": (.children[1].children[1].href | helpers::urlresolve("https://bea.aero/")),
"guid": (.children[1].children[1].href | helpers::urlresolve("https://bea.aero/")),
"pubDate": (
[(.children[0].children[1].children[].children[].children // [])[].datetime | strings][0]
| strptime("%Y-%m-%d")
| mktime
| strftime("%a, %d %b %Y %T %z")
),
"georss:point": (.children[2].text | [match("', (-?[0-9.]+), (-?[0-9.]+)") | .captures[].string] | join(" "))
}
]
}
}
}