itsb/jq/saia.jq

37 lines
1.2 KiB
Plaintext

# SAIA feed generator
# Required arguments:
# $title: Feed title
# $language: ISO 639-1 language code (sv or en)
# $description: Feed description
# $link: Feed link
# Expects pup JSON output holding <div class="desc"> 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": $title,
"description": $description,
"link": $link,
"language": ($language + "-SE"),
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://www.rssboard.org/rss-specification",
"ttl": 1440,
"generator": "ITSB",
"item": [.[] | {
"title": .children[0].text,
"description": .children[1].text,
"link": .children[0].href,
"pubDate": (
.children[1].text
| capture("(?:published|Publiceringsdatum)\\s*:\\s*(?<date>[0-9-]+)").date
| strptime("%Y-%m-%d")
| mktime
| strftime("%a, %d %b %Y %T %z")
)
}]
}
}
}