itsb/jq/tsib.jq

30 lines
1.2 KiB
Plaintext

# Transport Safety Investigation Bureau (Singapore) feed generator
# Required arguments:
# $type: Feed type (Aviation or Marine)
# $link: Feed link
# 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": "TSIB \($type)",
"description": "Transport Safety Investigation Bureau \($type) accident reports",
"link": $link,
"language": "en-SG",
"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 | .[:index(" (PDF")]) + " - " + .children[2].text),
"link": (.children[3].children[0].href | helpers::urlresolve($link)),
"guid": (.children[3].children[0].href | helpers::urlresolve($link)),
"pubDate": (.children[0].text | strptime("%d %b %Y") | mktime | strftime("%a, %d %b %Y %T %z"))
}]
}
}
}