aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/feed/feed.go8
-rw-r--r--internal/feed/parse.go8
2 files changed, 14 insertions, 2 deletions
diff --git a/internal/feed/feed.go b/internal/feed/feed.go
index 59c15f2..cd906a2 100644
--- a/internal/feed/feed.go
+++ b/internal/feed/feed.go
@@ -14,7 +14,13 @@ type Feed struct {
Target []string
Url string
config.Options
- feed gofeed.Feed
+ feed *gofeed.Feed
+ items []feeditem
+}
+
+type feeditem struct {
+ *gofeed.Feed
+ *gofeed.Item
}
type Feeds map[string]*Feed
diff --git a/internal/feed/parse.go b/internal/feed/parse.go
index a38be92..00b6aff 100644
--- a/internal/feed/parse.go
+++ b/internal/feed/parse.go
@@ -19,10 +19,16 @@ func parseFeed(feed *Feed) error {
ctx, cancel := context()
defer cancel()
fp := gofeed.NewParser()
- if _, err := fp.ParseURLWithContext(feed.Url, ctx); err != nil {
+ parsedFeed, err := fp.ParseURLWithContext(feed.Url, ctx)
+ if err != nil {
return fmt.Errorf("while fetching %s from %s: %w", feed.Name, feed.Url, err)
}
+ feed.feed = parsedFeed
+ feed.items = make([]feeditem, len(parsedFeed.Items))
+ for _, item := range parsedFeed.Items {
+ feed.items = append(feed.items, feeditem{parsedFeed, item})
+ }
return nil
}