International Transport Safety Bureau: centralizing every transport accident report into RSS feeds http://tilde.town/~lucidiot/itsb/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

50 lines
1.9 KiB

# AAIA 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.
# Expected variables:
# $lang: Language code, without the country code (en/zh-Hans/zh-Hant).
# $link: Link to the investigation list.
import "./helpers" as helpers;
{
"rss": {
"@version": "2.0",
"channel": {
"title": "AAIA (\($lang))",
"description": "Air Accident Investigation Authority reports",
"link": $link,
"language": "\($lang)-HK",
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://www.rssboard.org/rss-specification",
"ttl": 1440,
"generator": "ITSB",
"item": [
.[].children // []
# Ignore empty lines
| select(length)
| . as $data
# Grab all the report links, as we will use the last one as the link and put all of them in the description
| [
.[2:][].children
| ..
| select(.tag? == "a")
| .href |= helpers::urlresolve($link)
]
| {
"title": ($data[1].text // $data[1].children[0].text),
"link": .[-1].href,
"description": (
[.[] | "<li><a href=\"\(.href)\" target=\"_blank\">\(.text)</a></li>"]
| join("")
| "<ul>\(.)</ul>"
),
"pubDate": (
$data[0].text // $data[0].children[0].text
| if $lang == "en" then strptime("%d %B %Y") | mktime else helpers::parse_chinese_date end
| strftime("%a, %d %b %Y %T %z")
)
}
]
}
}
}