46 lines
1.8 KiB
Plaintext
46 lines
1.8 KiB
Plaintext
# Isle of Man Ship Registry feed generator
|
|
# Expects pup JSON output holding <a> 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": "IoM Ship Registry reports",
|
|
"description": "Isle of Man Ship Registry casualty reports",
|
|
"link": "https://www.iomshipregistry.com/forms-reports/casualty-reports/",
|
|
"language": "en-im",
|
|
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
|
|
"docs": "https://www.rssboard.org/rss-specification",
|
|
"ttl": 1440,
|
|
"generator": "ITSB",
|
|
"item": [
|
|
.[]
|
|
| . as $item
|
|
| [.children[] | select(.tag == "a")][0]
|
|
| {
|
|
"title": .title,
|
|
"link": (.href | helpers::urlresolve("https://www.iomshipregistry.com/forms-reports/casualty-reports/")),
|
|
"guid": {
|
|
"@isPermaLink": "true",
|
|
"#text": (.href | helpers::urlresolve("https://www.iomshipregistry.com/forms-reports/casualty-reports/"))
|
|
}
|
|
}
|
|
# Optional pubDate
|
|
| .pubDate = try (
|
|
# Get the entire paragraph as a string
|
|
[$item|..|.text?|strings]
|
|
| add
|
|
# Look for the year between brackets
|
|
| [scan("\\([0-9]+\\)")][0]
|
|
| strptime("(%Y)")
|
|
# Add 1 day because it assumes YYYY-00-00, which is Dec 31st of the previous year
|
|
| mktime + 86400
|
|
| strftime("%a, %d %b %Y %T %z")
|
|
)
|
|
]
|
|
}
|
|
}
|
|
}
|