itsb/jq/daai.jq

41 lines
1.6 KiB
Plaintext

# DAAI 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": "DAAI",
"description": "Namibian Directorate of Aircraft Accidents and Investigation reports",
"link": "https://mwt.gov.na/published-daai-report",
"language": "en-na",
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://www.rssboard.org/rss-specification",
"ttl": 1440,
"generator": "ITSB",
"item": [
.[].children
# Only include rows that contain hyperlinks, to skip blank rows or headers
| select(try .[].children[].tag == "a")
| {
"title": "\(.[1].children[0].text) - \(.[2].children[0].text) \(.[3].children[0].children[0].text) - \(.[-1].children[-1].text)",
"link": (.[3].children[0].children[0].href | helpers::urlresolve("https://mwt.gov.na/published-daai-report")),
"category": [
[.[1].children[0].text, .[-1].children[-1].text][]
| {
"@domain": "https://mwt.gov.na",
"#text": .
}
]
}
| .guid = {
"@isPermaLink": "true",
"#text": .link
}
]
}
}
}