DAAI custom feed, close #52
This commit is contained in:
parent
ba26077a8d
commit
28f2175950
|
@ -237,3 +237,10 @@ saia_build sv 204 'SHK Spärbunden' 'Svenska Statens haverikommission Spårbunde
|
|||
saia_build sv 202 'SHK Luftfart' 'Svenska Statens haverikommission luftfart olycksrapporter' air.xml
|
||||
saia_build sv 205 'SHK Sjöfart' 'Svenska Statens haverikommission sjöfart olycksrapporter' marine.xml
|
||||
saia_build sv 206 'SHK Militär' 'Svenska Statens haverikommission militär olycksrapporter' mil.xml
|
||||
|
||||
log Building DAAI feed to $DIR/feeds/daai.xml
|
||||
curl -sk -H 'User-Agent: Mozilla/1.0' https://mwt.gov.na/web/mwt/published-reports \
|
||||
| pup 'table json{}' \
|
||||
| jq -L $DIR/jq -f $DIR/jq/daai.jq \
|
||||
| json2xml > $DIR/feeds/daai.xml.new \
|
||||
&& mv $DIR/feeds/daai.xml.new $DIR/feeds/daai.xml
|
||||
|
|
24
index.html
24
index.html
|
@ -840,6 +840,30 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>Directorate of Aviation Accidents and Investigation</h3>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Language</strong></td>
|
||||
<td>English</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Type</strong></td>
|
||||
<td>Aviation</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Frequency</strong></td>
|
||||
<td>3-5 reports/year</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Feed</strong></td>
|
||||
<td>
|
||||
<a href="feeds/daai.xml" target="_blank"><img src="img/rss.gif" alt="RSS" /></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
# DAAI feed generator
|
||||
# Expects pup JSON output holding <table> 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": "DAAI",
|
||||
"description": "Namibian Directorate of Aircraft Accidents and Investigation reports",
|
||||
"link": "https://mwt.gov.na/web/mwt/published-reports",
|
||||
"language": "en-na",
|
||||
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
|
||||
"docs": "https://www.rssboard.org/rss-specification",
|
||||
"ttl": 1440,
|
||||
"generator": "ITSB",
|
||||
"item": [
|
||||
# Ignore table headers
|
||||
.[].children[].children[2:][]
|
||||
# Ignore empty lines
|
||||
| select(.children[3].children)
|
||||
| {
|
||||
"title": (
|
||||
# Accident/Incident
|
||||
(.children[1] | [..|.text?|strings][0])
|
||||
+ " - "
|
||||
# Aircraft type
|
||||
+ (.children[2] | [..|.text?|strings][0])
|
||||
+ " "
|
||||
# Aircraft registration
|
||||
+ (.children[3] | [..|.text?|strings][0])
|
||||
+ " - "
|
||||
# Report type (final/preliminary)
|
||||
+ (.children[4] | [..|.text?|strings][0])
|
||||
),
|
||||
"link": (.children[3].children[0].href | helpers::urlresolve("https://mwt.gov.na/web/mwt/published-reports")),
|
||||
"pubDate": ((.children[0] | [..|.text?|strings][0]) | gsub("\\s+"; " ") | strptime("%d %B %Y") | mktime | strftime("%a, %d %b %Y %T %z")),
|
||||
"guid": {
|
||||
"@isPermaLink": "true",
|
||||
"#text": (.children[3].children[0].href | helpers::urlresolve("https://mwt.gov.na/web/mwt/published-reports"))
|
||||
},
|
||||
"category": [
|
||||
{
|
||||
"@domain": "https://mwt.gov.na",
|
||||
"#text": (.children[1] | [..|.text?|strings][0])
|
||||
},
|
||||
{
|
||||
"@domain": "https://mwt.gov.na",
|
||||
"#text": (.children[4] | [..|.text?|strings][0])
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue