Add TSIB feeds, close #7

This commit is contained in:
Lucidiot 2020-07-19 16:52:50 +02:00
parent 6b7c55161f
commit 8cdb9ce4fb
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
4 changed files with 78 additions and 0 deletions

View File

@ -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' \

BIN
img/rss-marine.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

View File

@ -625,6 +625,35 @@
</td>
</tr>
</table>
<h3>Transport Safety Investigation Bureau</h3>
<table>
<tbody>
<tr>
<td><strong>Country</strong></td>
<td>Singapore</td>
</tr>
<tr>
<td><strong>Language</strong></td>
<td>English</td>
</tr>
<tr>
<td><strong>Types</strong></td>
<td>Aviation, Marine</td>
</tr>
<tr>
<td><strong>Frequency</strong></td>
<td>10 reports/year</td>
</tr>
<tr>
<td><strong>Feeds</strong></td>
<td>
<a href="feeds/tsib/air.xml" target="_blank"><img src="img/rss-aviation.gif" /></a>
<a href="feeds/tsib/marine.xml" target="_blank"><img src="img/rss-marine.gif" /></a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

28
jq/tsib.jq Normal file
View File

@ -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 <tr> 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"))
}]
}
}
}