ÚZPLN custom feeds, close #1

This commit is contained in:
Lucidiot 2020-03-31 22:47:53 +02:00
parent bf5d976280
commit b7423a1c8c
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
4 changed files with 84 additions and 3 deletions

View File

@ -129,3 +129,24 @@ curl -s 'https://www.bfu-web.de/DE/Publikationen/Untersuchungsberichte/untersuch
| jq -f $DIR/jq/bfu/de.jq \
| json2xml > $DIR/feeds/bfu/de.xml.new \
&& mv $DIR/feeds/bfu/de.xml.new $DIR/feeds/bfu/de.xml
log Building UZPLN English feed to $DIR/feeds/uzpln/en.xml
mkdir -p $DIR/feeds/uzpln
curl -s 'http://www.uzpln.cz/en/reports' \
| pup 'table.table tbody tr:not(:first-child) json{}' \
| jq -f $DIR/jq/uzpln.jq \
--arg language 'en' \
--arg description 'Air Accidents Investigation Institute' \
--arg link 'http://www.uzpln.cz/en/reports' \
| json2xml > $DIR/feeds/uzpln/en.xml.new \
&& mv $DIR/feeds/uzpln/en.xml.new $DIR/feeds/uzpln/en.xml
log Building UZPLN Czech feed to $DIR/feeds/uzpln/cz.xml
curl -s 'http://www.uzpln.cz/zpravy-ln' \
| pup 'table.table tbody tr:not(:first-child) json{}' \
| jq -f $DIR/jq/uzpln.jq \
--arg language 'cz' \
--arg description 'Ústav pro odborné Zjišťování Příčin Leteckých Nehod' \
--arg link 'http://www.uzpln.cz/zpravy-ln' \
| json2xml > $DIR/feeds/uzpln/cz.xml.new \
&& mv $DIR/feeds/uzpln/cz.xml.new $DIR/feeds/uzpln/cz.xml

BIN
img/rss-czech.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

View File

@ -425,7 +425,7 @@
<td>Denmark</td>
</tr>
<tr>
<td><strong>Language</strong></td>
<td><strong>Languages</strong></td>
<td>Danish, English</td>
</tr>
<tr>
@ -454,7 +454,7 @@
<td>Denmark</td>
</tr>
<tr>
<td><strong>Language</strong></td>
<td><strong>Languages</strong></td>
<td>Danish, English</td>
</tr>
<tr>
@ -480,7 +480,7 @@
<td>Germany</td>
</tr>
<tr>
<td><strong>Language</strong></td>
<td><strong>Languages</strong></td>
<td>German, English</td>
</tr>
<tr>
@ -500,6 +500,38 @@
</tr>
</tbody>
</table>
<h3>Air Accidents Investigation Institute</h3>
<table>
<tbody>
<tr>
<td><strong>Country</strong></td>
<td>Czech Republic</td>
</tr>
<tr>
<td><strong>Languages</strong></td>
<td>Czech, English</td>
</tr>
<tr>
<td><strong>Types</strong></td>
<td>Aviation</td>
</tr>
<tr>
<td><strong>Frequency</strong></td>
<td>
Czech: 10-20 reports/year<br />
English: &lt;1 report/year
</td>
</tr>
<tr>
<td><strong>Feeds</strong></td>
<td>
<a href="feeds/uzpln/cz.xml" target="_blank"><img src="img/rss-czech.gif" /></a>
<a href="feeds/uzpln/en.xml" target="_blank"><img src="img/rss-english.gif" /></a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

28
jq/uzpln.jq Normal file
View File

@ -0,0 +1,28 @@
# ÚZPLN feed generator
# Required arguments:
# $language: Feed language
# $description: Feed description
# $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.
{
"rss": {
"@version": "2.0",
"channel": {
"title": ("ÚZPLN (" + $language + ")"),
"description": $description,
"link": $link,
"language": $language,
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://cyber.harvard.edu/rss/rss.html",
"ttl": 86400,
"generator": "ITSB",
"item": [.[] | {
"title": (.children[4].text + " - " + .children[2].text),
"link": ("http://www.uzpln.cz" + .children[5].children[0].href),
"pubDate": (.children[0].text | strptime("%Y-%m-%d") | mktime | strftime("%a, %d %b %Y %T %z"))
}]
}
}
}