itsb/jq/denmark.jq

40 lines
1.7 KiB
Plaintext

# Denmark feed generator
# Compatible with AIBD Aviation https://en.havarikommissionen.dk/aviation-archive/
# Compatible with AIBD Rail https://en.havarikommissionen.dk/railway-archive/
# Compatible with DMAIB https://dmaib.com/reports/?categorizations=9510
# Required arguments:
# $title: Channel title
# $description: Channel description
# $link: Channel link
# Expects pup JSON output holding <li> tags, outputs xmltodict-compatible JSON
# WARNING: Dates are locale-sensitive; the RSS feed might not generate correctly with another locale.
{
"rss": {
"@version": "2.0",
"@xmlns:media": "http://search.yahoo.com/mrss/",
"channel": {
"title": $title,
"description": $description,
"link": $link,
"language": "en",
"pubDate": (now | strftime("%a, %d %b %Y %T %z")),
"docs": "https://cyber.harvard.edu/rss/rss.html",
"ttl": 86400,
"generator": "ITSB",
"item": [.[] | {
"title": first(.children[-1].children[] | select(.tag == "h3")).children[0].text,
"description": first(.children[-1].children[] | select(.tag == "p")).text,
"link": .["data-url"],
"pubDate": (first(.children[-1].children[] | select(.class == "date")).text[-10:] | strptime("%d-%m-%Y") | mktime | strftime("%a, %d %b %Y %T %z")),
"category": [.children[-1].children[] | select(.class == "labels") | .children[].text],
"media:thumbnail": (
if .children[0].class == "media-left" then {
"@url": .children[0].children[0].src
} else empty end
)
}]
}
}
}