Update DAAI feed

This commit is contained in:
Lucidiot 2021-05-14 08:46:47 +02:00
parent 8f5c337074
commit 42d156fec0
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
2 changed files with 9 additions and 35 deletions

View File

@ -820,10 +820,9 @@
<frequency>3-5 reports/year</frequency>
<feed format="rss" lang="English" id="daai-rss">
<curl>
<url verify-ssl="false">https://mwt.gov.na/web/mwt/published-reports</url>
<header name="User-Agent">Mozilla/1.0</header>
<url verify-ssl="false">https://mwt.gov.na/published-daai-report/-/document_library/PVB0Gp2amxBo/view/1344073?_com_liferay_document_library_web_portlet_DLPortlet_INSTANCE_PVB0Gp2amxBo_displayStyle=list</url>
</curl>
<pup>table</pup>
<pup>tr[data-title]</pup>
<jq path="daai.jq" />
<json2xml />
<output>daai.xml</output>

View File

@ -1,5 +1,5 @@
# DAAI feed generator
# Expects pup JSON output holding <table> tags, outputs xmltodict-compatible JSON
# 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;
@ -16,40 +16,15 @@ import "./helpers" as helpers;
"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")),
"title": .["data-title"],
"link": (.children[0].children[0].href | sub("\\?.*$"; "")),
"pubDate": (.children[3].children[0].onmouseover | match("&#39;(.*)&#39;").captures[0].string | strptime("%e/%m/%y %I:%M %p") | 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])
}
]
"#text": (.children[0].children[0].href | sub("\\?.*$"; ""))
}
}
]
}