Initial commit.

This commit is contained in:
Kyle Isom 2023-05-23 19:13:26 -07:00
commit f12e7d4f51
3 changed files with 104 additions and 0 deletions

55
feed/feed.go Normal file
View File

@ -0,0 +1,55 @@
package feed
import (
"time"
"github.com/mmcdole/gofeed"
)
type Entry struct {
Title string
Link string
Published time.Time
Categories []string
}
func EntryFromFeed(item *gofeed.Item) *Entry {
t := time.Now()
if item.UpdatedParsed != nil {
t = *item.UpdatedParsed
}
e := &Entry{
Title: item.Title,
Link: item.Link,
Published: t,
Categories: item.Categories,
}
return e
}
type Feed struct {
Title string
Link string
Updated time.Time
Entries []*Entry
}
func NewFromFeed(feed *gofeed.Feed) *Feed {
t := time.Now()
if feed.UpdatedParsed != nil {
t = *feed.UpdatedParsed
}
f := &Feed{
Title: feed.Title,
Link: feed.Link,
Updated: t,
}
for _, item := range feed.Items {
f.Entries = append(f.Entries, EntryFromFeed(item))
}
return f
}

17
go.mod Normal file
View File

@ -0,0 +1,17 @@
module git.wntrmute.dev/kyle/locator
require (
github.com/PuerkitoBio/goquery v1.8.0 // indirect
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gregdel/pushover v1.2.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mmcdole/gofeed v1.2.1 // indirect
github.com/mmcdole/goxpp v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/text v0.5.0 // indirect
)
go 1.20

32
main.go Normal file
View File

@ -0,0 +1,32 @@
package main
import (
"os"
"time"
"github.com/davecgh/go-spew/spew"
"github.com/mmcdole/gofeed"
)
var updateCycle = time.Minute
func checkFeed() error {
fp := gofeed.NewParser()
feed, err := fp.ParseURL("https://rpilocator.com/feed/")
if err != nil {
return err
}
f, err := os.Create("feed.txt")
if err != nil {
return err
}
defer f.Close()
spew.Fdump(f, feed)
return nil
}
func main() {
checkFeed()
}