2023-09-24 20:57:56 +00:00
|
|
|
// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2023-09-21 18:03:21 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/mmcdole/gofeed"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getRSSReleases(p project) (project, error) {
|
|
|
|
fp := gofeed.NewParser()
|
|
|
|
feed, err := fp.ParseURL(p.URL + "/releases.atom")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
return p, err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, item := range feed.Items {
|
|
|
|
p.Releases = append(p.Releases, release{
|
|
|
|
Tag: bmStrict.Sanitize(item.Title),
|
|
|
|
Content: bmUGC.Sanitize(item.Content),
|
|
|
|
URL: bmStrict.Sanitize(item.Link),
|
|
|
|
Date: *item.PublishedParsed,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Doesn't seem to work?
|
|
|
|
// sort.Slice(p.Releases, func(i, j int) bool { return p.Releases[i].Date.After(p.Releases[j].Date) })
|
|
|
|
|
|
|
|
return p, nil
|
|
|
|
}
|