Rewrite BfU feeds, close #120

This commit is contained in:
~lucidiot 2022-12-05 16:11:47 +01:00
parent 1491017e8e
commit ac1ef15a8f
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
3 changed files with 31 additions and 46 deletions

View File

@ -467,19 +467,27 @@
<url>https://www.bfu-web.de/</url>
<feed format="rss" lang="English" id="bfu-en">
<curl>
<url>https://www.bfu-web.de/EN/Publications/Investigation%20Report/reports_node.html?cms_gts=238148_list%253DdateOfIssue_dt%252Bdesc</url>
<url>https://www.bfu-web.de/SiteGlobals/Forms/Suche/EN/Untersuchungsberichtesuche_Formular.html</url>
</curl>
<pup>table.links tbody tr</pup>
<jq path="bfu/en.jq" />
<pup>.Publication &gt; .columns</pup>
<jq path="bfu.jq">
<arg name="title">BfU English</arg>
<arg name="language">en-DE</arg>
<arg name="link">https://www.bfu-web.de/SiteGlobals/Forms/Suche/EN/Untersuchungsberichtesuche_Formular.html</arg>
</jq>
<json2xml />
<output>bfu/en.xml</output>
</feed>
<feed format="rss" lang="German" id="bfu-de">
<curl>
<url>https://www.bfu-web.de/DE/Publikationen/Untersuchungsberichte/untersuchungsberichte_node.html?cms_gts=235998_list%253DdateOfIssue_dt%252Bdesc</url>
<url>https://www.bfu-web.de/SiteGlobals/Forms/Suche/Untersuchungsberichtesuche_Formular.html</url>
</curl>
<pup>table.links tbody tr</pup>
<jq path="bfu/de.jq" />
<pup>.Publication &gt; .columns</pup>
<jq path="bfu.jq">
<arg name="title">BfU Deutsch</arg>
<arg name="language">de-DE</arg>
<arg name="link">https://www.bfu-web.de/SiteGlobals/Forms/Suche/EN/Untersuchungsberichtesuche_Formular.html</arg>
</jq>
<json2xml />
<output>bfu/de.xml</output>
</feed>

View File

@ -1,5 +1,9 @@
# BFU English feed generator
# Expects pup JSON output holding <tr> tags, outputs xmltodict-compatible JSON
# BfU feed generator
# Required arguments:
# $title: Channel title
# $language: Channel language
# $link: Channel link
# Expects pup JSON output holding <div class="columns"> tags, outputs xmltodict-compatible JSON
# WARNING: Dates are locale-sensitive; the RSS feed might not generate correctly with another locale.
import "./helpers" as helpers;
@ -7,24 +11,28 @@ import "./helpers" as helpers;
"rss": {
"@version": "2.0",
"channel": {
"title": "BFU Deutsch",
"title": $title,
"description": "Bundesstelle für Flugunfalluntersuchung",
"link": "https://www.bfu-web.de/DE/Publikationen/Untersuchungsberichte/untersuchungsberichte_node.html?cms_gts=235998_list%253DdateOfIssue_dt%252Bdesc",
"language": "de-DE",
"link": $link,
"language": $language,
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://www.rssboard.org/rss-specification",
"ttl": 1440,
"generator": "ITSB",
"item": [.[] | {
"title": (.children[3].children[0].text + ": " + .children[2].text + ", " + .children[1].text),
"item": [.[].children | {
"title": .[0].children[0].children[0].text,
"link": (
.children[3].children[0].href
.[0].children[0].href
| helpers::urlparse
# Remove jsessionid path parameter
| .params = null
| helpers::urlresolve("https://www.bfu-web.de")
),
"pubDate": (.children[0].text | strptime("%d.%m.%Y") | mktime | strftime("%a, %d %b %Y %T %z"))
"category": {
"@domain": "https://www.bfu-web.de",
"#text": .[0].children[0].children[1].children[0].text
},
"description": ([.[1:][].children[].text | "<p>\(.)</p>"] | join("\n"))
}]
}
}

View File

@ -1,31 +0,0 @@
# BFU English 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.
import "./helpers" as helpers;
{
"rss": {
"@version": "2.0",
"channel": {
"title": "BFU English",
"description": "Bundesstelle für Flugunfalluntersuchung",
"link": "https://www.bfu-web.de/EN/Publications/Investigation%20Report/reports_node.html?cms_gts=238148_list%253DdateOfIssue_dt%252Bdesc",
"language": "en-DE",
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://www.rssboard.org/rss-specification",
"ttl": 1440,
"generator": "ITSB",
"item": [.[] | {
"title": (.children[3].children[0].text + ": " + .children[2].text + ", " + .children[1].text),
"link": (
.children[3].children[0].href
| helpers::urlparse
# Remove jsessionid path parameter
| .params = null
| helpers::urlresolve("https://www.bfu-web.de")
),
"pubDate": (.children[0].text | strptime("%Y.%m.%d") | mktime | strftime("%a, %d %b %Y %T %z"))
}]
}
}
}