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("'"; "'")), + "description": ( + [ + .children[0].children[1].children[].children + | .[0].text + " : " + ((.[1].children[0] | .text // .children[0].text) // .[1].text) + | gsub("'"; "'") + ] + | join("") + | "\(.)" + ), + "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(" ")) + } + ] + } + } +}