itsb/jq/taiid.jq

40 lines
1.4 KiB
Plaintext

# TAIID feed generator
# Required arguments:
# $title: Feed title
# $language: ISO 639-1 language code (lt or en)
# $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.
import "./helpers" as helpers;
{
"rss": {
"@version": "2.0",
"channel": {
"title": $title,
"description": $description,
"link": $link,
"language": ($language + "-LT"),
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://www.rssboard.org/rss-specification",
"ttl": 1440,
"generator": "ITSB",
"item": [
.[]
# Ignore reports without links
| select(.children[-2].children != null)
| {
"title": .children[-2].children[0].text,
"link": (.children[-2].children[0].href | helpers::urlresolve($link)),
"guid": {
"@isPermaLink": "true",
"#text": (.children[-2].children[0].href | helpers::urlresolve($link))
},
"pubDate": (.children[-3].text | strptime("%Y-%m-%d") | mktime | strftime("%a, %d %b %Y %T %z"))
}
]
}
}
}