diff --git a/feedgen.sh b/feedgen.sh index dc80e9f..ed15fe8 100755 --- a/feedgen.sh +++ b/feedgen.sh @@ -78,6 +78,28 @@ curl -s 'https://en.havarikommissionen.dk/railway-archive/' \ | json2xml -s -ns 'http://search.yahoo.com/mrss/' media > $DIR/feeds/aibd/rail.xml.new \ && mv $DIR/feeds/aibd/rail.xml.new $DIR/feeds/aibd/rail.xml +log Building TTSB Aviation English feed to $DIR/feeds/ttsb/en/aviation.xml +mkdir -p $DIR/feeds/ttsb/en +curl -s 'https://www.ttsb.gov.tw/english/16051/16052/16053/16058/Lpsimplelist?PageSize=1000' \ + | pup '#LP-ContentPage .TableList table tbody tr json{}' \ + | jq -L $DIR/jq -f $DIR/jq/ttsb.jq \ + --arg title 'TTSB Aviation' \ + --arg lang 'en-TW' \ + --arg link 'https://www.ttsb.gov.tw/english/16051/16052/16053/16058/Lpsimplelist?PageSize=1000' \ + | json2xml > $DIR/feeds/ttsb/en/aviation.xml.new \ + && mv $DIR/feeds/ttsb/en/aviation.xml.new $DIR/feeds/ttsb/en/aviation.xml + +log Building TTSB Aviation Chinese feed to $DIR/feeds/ttsb/zh/aviation.xml +mkdir -p $DIR/feeds/ttsb/zh +curl -s 'https://www.ttsb.gov.tw/1133/1154/1155/1159/Lpsimplelist?PageSize=1000' \ + | pup '#LP-ContentPage .TableList table tbody tr json{}' \ + | jq -L $DIR/jq -f $DIR/jq/ttsb.jq \ + --arg title '國家運輸安全調查委員會' \ + --arg lang 'zh-Hant-TW' \ + --arg link 'https://www.ttsb.gov.tw/1133/1154/1155/1159/Lpsimplelist?PageSize=1000' \ + | json2xml > $DIR/feeds/ttsb/zh/aviation.xml.new \ + && mv $DIR/feeds/ttsb/zh/aviation.xml.new $DIR/feeds/ttsb/zh/aviation.xml + log Building BFU English feed to $DIR/feeds/bfu/en.xml mkdir -p $DIR/feeds/bfu curl -s 'https://www.bfu-web.de/EN/Publications/Investigation%20Report/reports_node.html?cms_gts=238148_list%253DdateOfIssue_dt%252Bdesc' \ diff --git a/img/rss-chinese.gif b/img/rss-chinese.gif new file mode 100644 index 0000000..11d8c4f Binary files /dev/null and b/img/rss-chinese.gif differ diff --git a/index.html b/index.html index fc8b7c5..9dbe788 100644 --- a/index.html +++ b/index.html @@ -658,6 +658,42 @@ + +

Taiwan Transportation Safety Board

+ + + + + + + + + + + + + + + + + + + + + + + +
CountryTaiwan
LanguageTraditional Chinese, English
TypesAviation, rail, marine, highway
Frequency10 reports/year
Feeds + + + + + +
Aviation + Chinese RSS + English RSS +
+
diff --git a/jq/ttsb.jq b/jq/ttsb.jq new file mode 100644 index 0000000..75a84b1 --- /dev/null +++ b/jq/ttsb.jq @@ -0,0 +1,49 @@ +# Taiwan Transportation Safety Board Aviation feed generator +# Required arguments: +# $title: Feed title +# $lang: Feed language +# $link: Feed link +# Expects pup JSON output holding 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": $title, + "description": $title, + "link": $link, + "language": $lang, + "pubDate": (now | strftime("%a, %d %b %Y %T %z")), + "docs": "https://cyber.harvard.edu/rss/rss.html", + "ttl": 86400, + "generator": "ITSB", + "item": [.[] | { + "title": .children[2].children[0].title, + "description": [ + .children[3:][] + | ( + .["data-th"] + ": " + ( + .children[0].text + // .children[0].children[0].text + // "—" + ) + ) + ] | join("\n"), + "link": (.children[2].children[0].children[0].href | helpers::urlresolve($link)), + "pubDate": ( + .children[1].children[0].text + | strptime("%Y-%m-%d") + # strptime returns a [year, month, day, …] array + # To handle the Chinese calendar, which is sometimes used by the TTSB feeds, + # we add 1911 years to the parsed date when it is below 1998, + # 1999 being the year of their earliest investigation. + | .[0] |= if . <= 1998 then (. + 1911) else . end + | mktime + | strftime("%a, %d %b %Y %T %z") + ) + }] + } + } +}