This commit is contained in:
parent
cb680241a4
commit
52cb376335
2 changed files with 13 additions and 3 deletions
|
|
@ -6,4 +6,9 @@ kind = "Atom"
|
|||
|
||||
[[feeds]]
|
||||
url = "https://github.com/fatedier/frp/releases.atom"
|
||||
kind = "Atom"
|
||||
kind = "Atom"
|
||||
|
||||
[[feeds]]
|
||||
url = "https://forgejo.org/releases/rss.xml"
|
||||
kind = "RSSv2"
|
||||
timeFormat = "ddd',' dd MMM yyyy HH:mm:ss 'GMT'"
|
||||
|
|
@ -5,9 +5,10 @@ const
|
|||
atomTimeFormat* {.strdefine.} = "yyyy-MM-dd'T'HH:mm:ss'Z'"
|
||||
rssv2TimeFormat* {.strdefine.} = "ddd',' dd MMM yyyy HH:mm:ss ZZZ"
|
||||
|
||||
type RssFeed* = object # name:string
|
||||
type RssFeed* = object
|
||||
url*: string
|
||||
kind*: FeedType
|
||||
timeFormat*: string
|
||||
|
||||
proc parseAtomTime(s: string): DateTime =
|
||||
parse(s, atomTimeFormat)
|
||||
|
|
@ -48,7 +49,11 @@ proc mixRssFeeds*(feeds: seq[RssFeed], name, id, link, authorName, description:s
|
|||
entries[^1].items = entries[^1].items.mapIt(
|
||||
block:
|
||||
var item = it
|
||||
item.pubdate = some(getRssv2Time(item).format(atomTimeFormat))
|
||||
if feed.timeFormat.len != 0 and item.pubDate.isSome():
|
||||
# if the IDE screams at you here, ignore it
|
||||
item.pubdate = some(parse(item.pubDate.get(), feed.timeFormat).format(atomTimeFormat))
|
||||
else:
|
||||
item.pubdate = some(getRssv2Time(item).format(atomTimeFormat))
|
||||
item
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue