Add OEAIF feeds, close #41

This commit is contained in:
Lucidiot 2021-03-19 20:53:56 +01:00
parent 0f9408a6c2
commit 0685bdac52
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
2 changed files with 104 additions and 0 deletions

View File

@ -1064,5 +1064,68 @@
<output>ie-raiu.xml</output>
</feed>
</source>
<source id="oeaif">
<name>Organisme d'Enquête sur les Accidents et Incidents Ferroviaires</name>
<region>Belgium</region>
<type>Rail</type>
<frequency>3 reports/year</frequency>
<feed type="rail" lang="French" format="rss" id="oeaif-fr">
<curl>
<url>https://www.rail-investigation.be/wp-admin/admin-ajax.php</url>
<requestBody>action=filtreEnquete&amp;data[0][name]=enquete_etat&amp;data[0][value]=125</requestBody>
<header name="Cookie">wp-wpml_current_language=fr</header>
</curl>
<pup>tr</pup>
<jq path="oeaif.jq">
<arg name="title">OEAIF</arg>
<arg name="lang">fr</arg>
</jq>
<json2xml />
<output>oeaif/fr.xml</output>
</feed>
<feed type="rail" lang="Dutch" format="rss" id="oeaif-nl">
<curl>
<url>https://www.rail-investigation.be/wp-admin/admin-ajax.php</url>
<requestBody>action=filtreEnquete&amp;data[0][name]=enquete_etat&amp;data[0][value]=125</requestBody>
<header name="Cookie">wp-wpml_current_language=nl</header>
</curl>
<pup>tr</pup>
<jq path="oeaif.jq">
<arg name="title">OOIS</arg>
<arg name="lang">nl</arg>
</jq>
<json2xml />
<output>oeaif/nl.xml</output>
</feed>
<feed type="rail" lang="English" format="rss" id="oeaif-en">
<curl>
<url>https://www.rail-investigation.be/wp-admin/admin-ajax.php</url>
<requestBody>action=filtreEnquete&amp;data[0][name]=enquete_etat&amp;data[0][value]=125</requestBody>
<header name="Cookie">wp-wpml_current_language=en</header>
</curl>
<pup>tr</pup>
<jq path="oeaif.jq">
<arg name="title">RAIIU</arg>
<arg name="lang">en</arg>
</jq>
<json2xml />
<output>oeaif/en.xml</output>
</feed>
<feed type="rail" lang="German" format="rss" id="oeaif-de">
<curl>
<url>https://www.rail-investigation.be/wp-admin/admin-ajax.php</url>
<requestBody>action=filtreEnquete&amp;data[0][name]=enquete_etat&amp;data[0][value]=125</requestBody>
<header name="Cookie">wp-wpml_current_language=de</header>
</curl>
<pup>tr</pup>
<jq path="oeaif.jq">
<arg name="title">UfE</arg>
<arg name="lang">de</arg>
</jq>
<json2xml />
<output>oeaif/de.xml</output>
</feed>
</source>
</section>
</itsb>

41
jq/oeaif.jq Normal file
View File

@ -0,0 +1,41 @@
# OEAIF feed generator
# Expects pup JSON output holding <tr> tags, outputs xmltodict-compatible JSON
# WARNING: Dates are locale-sensitive; the RSS feed might not generate correctly with another locale.
# Expected variables:
# $title: Title of the feed
# $lang: Language code, without the country code (fr/en/nl/de)
{
"rss": {
"@version": "2.0",
"channel": {
"title": $title,
"description": $title,
"link": "https://www.rail-investigation.be/\($lang)/",
"language": "\($lang)-BE",
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://www.rssboard.org/rss-specification",
"ttl": 1440,
"generator": "ITSB",
"item": [.[] | {
"title": .children[2].text,
"description": (
[
([.children[1]] + .children[3:])[]
| (.["data-title"] + ": " + .text)
]
| join("</li><li>")
| "<ul><li>\(.)</li></ul>"
),
"link": .["data-href"],
"guid": .["data-href"],
"pubDate": (
.children[0].text
| strptime("%d/%m/%Y")
| mktime
| strftime("%a, %d %b %Y %T %z")
)
}]
}
}
}