itsb/jq/bea.jq

45 lines
1.9 KiB
Plaintext

# 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": [.[] | {
"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[]?.children[0].text | strings][0]
| strptime("%d/%m/%Y")
| mktime
| strftime("%a, %d %b %Y %T %z")
),
"georss:point": (.children[2].text | [match("', (-?[0-9.]+), (-?[0-9.]+)") | .captures[].string] | join(" "))
}]
}
}
}