From d8d47b6cbbb263666a32151dabc56d345b77664f Mon Sep 17 00:00:00 2001 From: Lucidiot Date: Sat, 14 Dec 2019 17:42:43 +0100 Subject: [PATCH] Custom feeds for Denmark's AIBD and DMAIB --- feedgen.sh | 31 ++++++++++++++++++++++++++++++ index.html | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ jq/denmark.jq | 39 ++++++++++++++++++++++++++++++++++++++ jq/taic.jq | 2 +- 4 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 jq/denmark.jq diff --git a/feedgen.sh b/feedgen.sh index 973da11..915195b 100755 --- a/feedgen.sh +++ b/feedgen.sh @@ -65,3 +65,34 @@ curl -s 'https://jtsb.mlit.go.jp/jtsb/ship/ship-kensaku-list.php?sort=desc&by=p' | 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 + +echo Building AIBD Aviation feed to $DIR/feeds/aibd/aviation.xml +mkdir -p $DIR/feeds/aibd +curl -s 'https://en.havarikommissionen.dk/aviation-archive/' \ + | pup 'ul.items > li[data-url] json{}' \ + | jq -f $DIR/jq/denmark.jq \ + --arg title 'AIBD Aviation' \ + --arg description 'Accident Investigation Board Denmark aviation accident reports' \ + --arg link 'https://en.havarikommissionen.dk/aviation-archive/' \ + | json2xml > $DIR/feeds/aibd/aviation.xml.new \ + && mv $DIR/feeds/aibd/aviation.xml.new $DIR/feeds/aibd/aviation.xml + +echo Building AIBD Rail feed to $DIR/feeds/aibd/rail.xml +curl -s 'https://en.havarikommissionen.dk/railway-archive/' \ + | pup 'ul.items > li[data-url] json{}' \ + | jq -f $DIR/jq/denmark.jq \ + --arg title 'AIBD Rail' \ + --arg description 'Accident Investigation Board Denmark railroad accident reports' \ + --arg link 'https://en.havarikommissionen.dk/railway-archive/' \ + | json2xml > $DIR/feeds/aibd/rail.xml.new \ + && mv $DIR/feeds/aibd/rail.xml.new $DIR/feeds/aibd/rail.xml + +echo Building DMAIB feed to $DIR/feeds/dmaib.xml +curl -s 'https://dmaib.com/reports/?categorizations=9510' \ + | pup 'ul.items > li[data-url] json{}' \ + | jq -f $DIR/jq/denmark.jq \ + --arg title 'DMAIB' \ + --arg description 'Danish Maritime Accident Investigation Board accident reports' \ + --arg link 'https://dmaib.com/reports/?categorizations=9510' \ + | json2xml > $DIR/feeds/dmaib.xml.new \ + && mv $DIR/feeds/dmaib.xml.new $DIR/feeds/dmaib.xml diff --git a/index.html b/index.html index a906d92..6828473 100644 --- a/index.html +++ b/index.html @@ -266,6 +266,58 @@ + +

Accident Investigation Board Denmark

+ + + + + + + + + + + + + + + + + + + + + + + +
CountryDenmark
LanguageDanish, English
TypesRail, aviation
Frequency10-20 reports/year
FeedsAviationRail
+ +

Danish Maritime Accident Investigation Board

+ + + + + + + + + + + + + + + + + + + + + + + +
CountryDenmark
LanguageDanish, English
TypesMarine
Frequency1-5 reports/year
Feedrss
diff --git a/jq/denmark.jq b/jq/denmark.jq new file mode 100644 index 0000000..cba075b --- /dev/null +++ b/jq/denmark.jq @@ -0,0 +1,39 @@ +# Denmark feed generator +# Compatible with AIBD Aviation https://en.havarikommissionen.dk/aviation-archive/ +# Compatible with AIBD Rail https://en.havarikommissionen.dk/railway-archive/ +# Compatible with DMAIB https://dmaib.com/reports/?categorizations=9510 +# Required arguments: +# $title: Channel title +# $description: Channel description +# $link: Channel 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. + +{ + "rss": { + "@version": "2.0", + "@xmlns:media": "http://search.yahoo.com/mrss/", + "channel": { + "title": $title, + "description": $description, + "link": $link, + "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": first(.children[-1].children[] | select(.tag == "h3")).children[0].text, + "description": first(.children[-1].children[] | select(.tag == "p")).text, + "link": .["data-url"], + "pubDate": (first(.children[-1].children[] | select(.class == "date")).text[-10:] | strptime("%d-%m-%Y") | mktime | strftime("%a, %d %b %Y %T %z")), + "category": [.children[-1].children[] | select(.class == "labels") | .children[].text], + "media:thumbnail": ( + if .children[0].class == "media-left" then { + "@url": .children[0].children[0].src + } else empty end + ) + }] + } + } +} diff --git a/jq/taic.jq b/jq/taic.jq index 292fb8f..786eb2b 100644 --- a/jq/taic.jq +++ b/jq/taic.jq @@ -13,7 +13,7 @@ "pubDate": (now | strftime("%a, %d %b %Y %T %z")), "docs": "https://cyber.harvard.edu/rss/rss.html", "ttl": 86400, - "generator": "ITSB", + "generator": "ITSB", "item": [.[] | { "title": .children[0].children[1].text, "description": .children[0].children[2].text,