From 8cdb9ce4fba50f0135cf254349c3a518cc1a0d54 Mon Sep 17 00:00:00 2001 From: Lucidiot Date: Sun, 19 Jul 2020 16:52:50 +0200 Subject: [PATCH] Add TSIB feeds, close #7 --- feedgen.sh | 21 +++++++++++++++++++++ img/rss-marine.gif | Bin 0 -> 206 bytes index.html | 29 +++++++++++++++++++++++++++++ jq/tsib.jq | 28 ++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 img/rss-marine.gif create mode 100644 jq/tsib.jq diff --git a/feedgen.sh b/feedgen.sh index 01b73c8..8355195 100755 --- a/feedgen.sh +++ b/feedgen.sh @@ -116,6 +116,27 @@ curl -s 'https://www.uzpln.cz/zpravy-ln' \ | json2xml > $DIR/feeds/uzpln/cz.xml.new \ && mv $DIR/feeds/uzpln/cz.xml.new $DIR/feeds/uzpln/cz.xml +log Building TSIB Marine feed to $DIR/feeds/tsib/marine.xml +mkdir -p $DIR/feeds/tsib +curl -s 'https://www.mot.gov.sg/about-mot/transport-safety-investigation-bureau/msib/investigation-report/' \ + | pup '.container-twelve .eight > .row:last-child tbody > tr json{}' \ + | jq -L $DIR/jq \ + -f $DIR/jq/tsib.jq \ + --arg type Marine \ + --arg link 'https://www.mot.gov.sg/about-mot/transport-safety-investigation-bureau/msib/investigation-report/' \ + | json2xml > $DIR/feeds/tsib/marine.xml.new \ + && mv $DIR/feeds/tsib/marine.xml.new $DIR/feeds/tsib/marine.xml + +log Building TSIB Aviation feed to $DIR/feeds/tsib/air.xml +curl -s 'https://www.mot.gov.sg/about-mot/transport-safety-investigation-bureau/aaib/investigation-report/' \ + | pup '.container-twelve .eight > .row:last-child tbody > tr json{}' \ + | jq -L $DIR/jq \ + -f $DIR/jq/tsib.jq \ + --arg type Aviation \ + --arg link 'https://www.mot.gov.sg/about-mot/transport-safety-investigation-bureau/aaib/investigation-report/' \ + | json2xml > $DIR/feeds/tsib/air.xml.new \ + && mv $DIR/feeds/tsib/air.xml.new $DIR/feeds/tsib/air.xml + log Building JTSB Aviation English feed to $DIR/feeds/jtsb/en/air.xml mkdir -p $DIR/feeds/jtsb/en curl -s 'https://www.mlit.go.jp/jtsb/airrep.html' \ diff --git a/img/rss-marine.gif b/img/rss-marine.gif new file mode 100644 index 0000000000000000000000000000000000000000..60ac0696341853326f6bf4dac1e808a2c40f68d4 GIT binary patch literal 206 zcmV;<05ShZNk%w1VNd`M0PzC=W@cvpW&ntYfdBvhA^8LV00000EC2ui08juA0007? zgpaAq?GMkGwAzca-n^R;gyKk+!62mS%C_zczr$zNCK~7Z-p&AM3x;sKqOnICPDT__ zbGRZ(r_xkaKsow=r=gcwB4SY!s~LO7mC + +

Transport Safety Investigation Bureau

+ + + + + + + + + + + + + + + + + + + + + + + +
CountrySingapore
LanguageEnglish
TypesAviation, Marine
Frequency10 reports/year
Feeds + + +
diff --git a/jq/tsib.jq b/jq/tsib.jq new file mode 100644 index 0000000..27288bc --- /dev/null +++ b/jq/tsib.jq @@ -0,0 +1,28 @@ +# Transport Safety Investigation Bureau (Singapore) feed generator +# Required arguments: +# $type: Feed type (Aviation or Marine) +# $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": "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://cyber.harvard.edu/rss/rss.html", + "ttl": 86400, + "generator": "ITSB", + "item": [.[] | { + "title": ((.children[3].children[0].text | .[:index(" (PDF")]) + " - " + .children[2].text), + "link": (.children[3].children[0].href | helpers::urlresolve($link)), + "pubDate": (.children[0].text | strptime("%d %b %Y") | mktime | strftime("%a, %d %b %Y %T %z")) + }] + } + } +}