itsb/jq/jtsb/en/rail.jq

34 lines
1.3 KiB
Plaintext

# JTSB rail feed generator (English version) from http://www.mlit.go.jp/jtsb/railrep.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.
{
"rss": {
"@version": "2.0",
"channel": {
"title": "JTSB Rail",
"description": "Japan Transport Safety Board railroad accident reports",
"link": "http://www.mlit.go.jp/jtsb/railrep.html",
"language": "en",
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://cyber.harvard.edu/rss/rss.html",
"ttl": 86400,
"generator": "ITSB",
"item": [.[] | {
"title": (
.children[0].children[0].text
+ " - "
+ .children[4].children[0].text
),
"description": (
.children[3].children[0].text
+ " - "
+ .children[5].children[0].text
),
"link": ("http://www.mlit.go.jp/jtsb/" + .children[-1].children[0].href),
"pubDate": (try (.children[1].children[0].text | strptime("%Y.%m.%d") | mktime | strftime("%a, %d %b %Y %T %z")))
}]
}
}
}