Fix dates and add subjects in RSS3

This commit is contained in:
Lucidiot 2021-04-05 23:45:42 +02:00
parent 6e86eee5fc
commit 7a359e53c2
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
1 changed files with 6 additions and 4 deletions

View File

@ -3,6 +3,7 @@
def ensure_array: (. // []) | if type == "array" then . else [.] end;
def ensure_string: if type == "array" then .[0] else . end | if type == "object" then .["#text"] else . end;
def parse_date: if .pubDate then .pubDate | strptime("%a, %d %b %Y %T %Z") | todateiso8601 else null end;
.rss.channel
| [{
@ -10,7 +11,7 @@ def ensure_string: if type == "array" then .[0] else . end | if type == "object"
"link": .link,
"description": .description,
"generator": .generator,
"last-modified": .pubDate,
"last-modified": parse_date,
"language": .language,
"rights": .copyright,
"creator": (.managingEditor // .webMaster),
@ -20,14 +21,15 @@ def ensure_string: if type == "array" then .[0] else . end | if type == "object"
"link": .link,
"description": .description,
"creator": .author,
"last-modified": .pubDate,
"last-modified": parse_date,
"guid": .guid,
"uri": (if (.guid|type) == "string" or .guid?["@isPermaLink"] != "false" then .guid else null end)
"uri": (if (.guid|type) == "string" or .guid?["@isPermaLink"] != "false" then .guid else null end),
"subject": (.category | ensure_array | map(ensure_string) | join(", "))
}]
| map([
map_values(ensure_string)
| to_entries[]
| select(.value | . != null and length)
| select(.value | . != null and length > 0)
| "\(.key): \(.value)"
# Ensure there are spaces after all newlines
| gsub("\n"; "\n ")