diff --git a/feedgen.sh b/feedgen.sh index 8976e6c..973da11 100755 --- a/feedgen.sh +++ b/feedgen.sh @@ -4,6 +4,7 @@ echo Building to $DIR/feeds mkdir -p $DIR/feeds if ! command -v json2xml >/dev/null 2>&1; then + echo "Adding $DIR/bin to PATH" PATH="$DIR/bin:$PATH" fi @@ -20,3 +21,47 @@ curl -s 'https://www.taic.org.nz/inquiries?order=field_publication_date&sort=des | jq -f $DIR/jq/taic.jq \ | json2xml > $DIR/feeds/taic.xml.new \ && mv $DIR/feeds/taic.xml.new $DIR/feeds/taic.xml + +echo Building JTSB Aviation English feed to $DIR/feeds/jtsb/en/air.xml +mkdir -p $DIR/feeds/jtsb/en +curl -s 'http://www.mlit.go.jp/jtsb/airrep.html' \ + | pup 'table.kankokuiken-en tr:not(:first-child) json{}' \ + | jq -f $DIR/jq/jtsb/en/air.jq \ + | json2xml > $DIR/feeds/jtsb/en/air.xml.new \ + && mv $DIR/feeds/jtsb/en/air.xml.new $DIR/feeds/jtsb/en/air.xml + +echo Building JTSB Rail English feed to $DIR/feeds/jtsb/en/rail.xml +curl -s 'http://www.mlit.go.jp/jtsb/railrep.html' \ + | pup 'table.kankokuiken-en tr:not(:first-child) json{}' \ + | jq -f $DIR/jq/jtsb/en/rail.jq \ + | json2xml > $DIR/feeds/jtsb/en/rail.xml.new \ + && mv $DIR/feeds/jtsb/en/rail.xml.new $DIR/feeds/jtsb/en/rail.xml + +echo Building JTSB Marine English feed to $DIR/feeds/jtsb/en/marine.xml +curl -s 'http://www.mlit.go.jp/jtsb/marrep.html' \ + | pup 'table.kankokuiken-en tr:not(:first-child) json{}' \ + | jq -f $DIR/jq/jtsb/en/marine.jq \ + | json2xml > $DIR/feeds/jtsb/en/marine.xml.new \ + && mv $DIR/feeds/jtsb/en/marine.xml.new $DIR/feeds/jtsb/en/marine.xml + +echo Building JTSB Aviation Japanese feed to $DIR/feeds/jtsb/jp/air.xml +mkdir -p $DIR/feeds/jtsb/jp +curl -s 'https://jtsb.mlit.go.jp/jtsb/aircraft/air-kensaku-list.php?sort=desc&by=p' \ + | pup 'table.jiko-information tr:not(:first-child) json{}' \ + | jq -f $DIR/jq/jtsb/jp/air.jq \ + | json2xml > $DIR/feeds/jtsb/jp/air.xml.new \ + && mv $DIR/feeds/jtsb/jp/air.xml.new $DIR/feeds/jtsb/jp/air.xml + +echo Building JTSB Rail Japanese feed to $DIR/feeds/jtsb/jp/rail.xml +curl -s 'https://jtsb.mlit.go.jp/jtsb/railway/rail-kensaku-list.php?sort=desc&by=p' \ + | pup 'table.jiko-information tr:not(:first-child) json{}' \ + | jq -f $DIR/jq/jtsb/jp/rail.jq \ + | json2xml > $DIR/feeds/jtsb/jp/rail.xml.new \ + && mv $DIR/feeds/jtsb/jp/rail.xml.new $DIR/feeds/jtsb/jp/rail.xml + +echo Building JTSB Marine Japanese feed to $DIR/feeds/jtsb/jp/marine.xml +curl -s 'https://jtsb.mlit.go.jp/jtsb/ship/ship-kensaku-list.php?sort=desc&by=p' \ + | pup 'table.jiko-information tr:not(:first-child) json{}' \ + | jq -f $DIR/jq/jtsb/jp/marine.jq \ + | json2xml > $DIR/feeds/jtsb/jp/marine.xml.new \ + && mv $DIR/feeds/jtsb/jp/marine.xml.new $DIR/feeds/jtsb/jp/marine.xml diff --git a/index.html b/index.html index 991a9fc..a906d92 100644 --- a/index.html +++ b/index.html @@ -193,7 +193,7 @@ Types - Road, rail, aviation, fluvial, ski lifts + Rail, aviation, marine Frequency @@ -231,6 +231,41 @@ + +

Japan Transport Safety Board

+ + + + + + + + + + + + + + + + + + + + + + + +
CountryJapan
LanguagesJapanese, English
TypesRail, aviation, marine
Frequency + Japanese: 100+ reports/year
+ English: 30-40 reports/year +
Feeds + +
diff --git a/jq/jtsb/en/air.jq b/jq/jtsb/en/air.jq new file mode 100644 index 0000000..74670ca --- /dev/null +++ b/jq/jtsb/en/air.jq @@ -0,0 +1,39 @@ +# JTSB aviation feed generator (English version) from http://www.mlit.go.jp/jtsb/airrep.html +# 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. + +{ + "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://cyber.harvard.edu/rss/rss.html", + "ttl": 86400, + "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": ("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"))) + }] + } + } +} diff --git a/jq/jtsb/en/marine.jq b/jq/jtsb/en/marine.jq new file mode 100644 index 0000000..d40fefb --- /dev/null +++ b/jq/jtsb/en/marine.jq @@ -0,0 +1,33 @@ +# JTSB marine feed generator (English version) from http://www.mlit.go.jp/jtsb/marrep.html +# 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. + +{ + "rss": { + "@version": "2.0", + "channel": { + "title": "JTSB Marine", + "description": "Japan Transport Safety Board marine accident reports", + "link": "http://www.mlit.go.jp/jtsb/marrep.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"))) + }] + } + } +} diff --git a/jq/jtsb/en/rail.jq b/jq/jtsb/en/rail.jq new file mode 100644 index 0000000..12cc421 --- /dev/null +++ b/jq/jtsb/en/rail.jq @@ -0,0 +1,33 @@ +# JTSB rail feed generator (English version) from http://www.mlit.go.jp/jtsb/railrep.html +# 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. + +{ + "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"))) + }] + } + } +} diff --git a/jq/jtsb/jp/air.jq b/jq/jtsb/jp/air.jq new file mode 100644 index 0000000..ac0c548 --- /dev/null +++ b/jq/jtsb/jp/air.jq @@ -0,0 +1,38 @@ +# JTSB aviation feed generator (Japanese version) from https://jtsb.mlit.go.jp/jtsb/aircraft/air-kensaku-list.php?sort=desc&by=p +# 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. + +{ + "rss": { + "@version": "2.0", + "channel": { + "title": "JTSB 航空報告", + "description": "運輸安全委員会 航空報告", + "link": "https://jtsb.mlit.go.jp/jtsb/aircraft/air-kensaku-list.php", + "language": "ja-JP", + "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[4].text + + " " + + .children[3].text + + .children[3].children[0].text + + " " + + .children[2].text + + " " + + .children[1].text + ), + "link": .children[5].children[2].href, + "pubDate": (try (.children[5].text | sub("[^0-9]"; ""; "g") | strptime("%Y%m%d") | mktime | strftime("%a, %d %b %Y %T %z"))) + }] + } + } +} diff --git a/jq/jtsb/jp/marine.jq b/jq/jtsb/jp/marine.jq new file mode 100644 index 0000000..1f716eb --- /dev/null +++ b/jq/jtsb/jp/marine.jq @@ -0,0 +1,35 @@ +# JTSB marine feed generator (Japanese version) from https://jtsb.mlit.go.jp/jtsb/ship/ship-kensaku-list.php?sort=desc&by=p +# 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. + +{ + "rss": { + "@version": "2.0", + "channel": { + "title": "JTSB 船舶報告", + "description": "運輸安全委員会 船舶報告", + "link": "https://jtsb.mlit.go.jp/jtsb/ship/ship-kensaku-list.php", + "language": "ja-JP", + "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[3].children[0].text + ), + "description": ( + .children[3].text + + " " + + .children[2].text + + " " + + .children[1].text + ), + "link": .children[4].children[2].href, + "pubDate": (try (.children[4].text | sub("[^0-9]"; ""; "g") | strptime("%Y%m%d") | mktime | strftime("%a, %d %b %Y %T %z"))) + }] + } + } +} diff --git a/jq/jtsb/jp/rail.jq b/jq/jtsb/jp/rail.jq new file mode 100644 index 0000000..507af92 --- /dev/null +++ b/jq/jtsb/jp/rail.jq @@ -0,0 +1,36 @@ +# JTSB rail feed generator (Japanese version) from https://jtsb.mlit.go.jp/jtsb/railway/rail-kensaku-list.php?sort=desc&by=p +# 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. + +{ + "rss": { + "@version": "2.0", + "channel": { + "title": "JTSB 鉄道報告", + "description": "運輸安全委員会 鉄道報告", + "link": "https://jtsb.mlit.go.jp/jtsb/railway/rail-kensaku-list.php", + "language": "ja-JP", + "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[3].children[0].text + ), + "description": ( + .children[3].text + + " " + + .children[2].text + + .children[2].children[0].text + + " " + + .children[1].text + ), + "link": .children[4].children[2].href, + "pubDate": (try (.children[4].text | sub("[^0-9]"; ""; "g") | strptime("%Y%m%d") | mktime | strftime("%a, %d %b %Y %T %z"))) + }] + } + } +}