itsb/jq/jtsb/en/air.jq

47 lines
1.8 KiB
Plaintext

# JTSB aviation feed generator (English version) from http://www.mlit.go.jp/jtsb/airrep.html
# 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": "JTSB Aviation",
"description": "Japan Transport Safety Board aviation accident reports",
"link": "http://www.mlit.go.jp/jtsb/airrep.html",
"language": "en",
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://www.rssboard.org/rss-specification",
"ttl": 1440,
"generator": "ITSB",
"item": [.[] | {
"title": (
.children[0].children[0].text
+ " - "
+ .children[2].children[0].text
+ " - "
+ .children[5].children[0].text
),
"description": (
.children[4].children[0].text
+ " "
+ .children[5].children[0].text
+ " operated by "
+ .children[3].children[0].text
+ " - "
+ .children[6].children[0].text
),
"link": (.children[-1].children[0].href|helpers::urlresolve("http://www.mlit.go.jp/jtsb/")),
"guid": (.children[-1].children[0].href|helpers::urlresolve("http://www.mlit.go.jp/jtsb/")),
"pubDate": (try (
.children[1].children[0].text
| strptime("%Y.%m.%d")
| mktime
| strftime("%a, %d %b %Y %T %z")
) catch [])
}]
}
}
}