rss: use filters hash relative to its own pvrs

This commit is contained in:
James Bayliss
2021-02-16 19:09:01 +00:00
parent 495c5a5c1a
commit 4476094add
7 changed files with 19 additions and 22 deletions

View File

@@ -30,7 +30,7 @@ func (c *Client) AddJob(feed feedItem) error {
cron: c.cron,
cache: c.cache,
cacheDuration: feed.CacheDuration,
cacheFiltersHash: c.cacheFiltersHash,
cacheFiltersHash: "",
}
// add pvrs
@@ -40,6 +40,7 @@ func (c *Client) AddJob(feed feedItem) error {
return fmt.Errorf("pvr object does not exist: %v", p)
}
job.pvrs[p] = po
job.cacheFiltersHash += po.GetFiltersHash()
}
// schedule job

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"github.com/l3uddz/nabarr/media"
"github.com/lucperkins/rek"
"sort"
"strings"
"time"
)
@@ -72,11 +71,6 @@ func (j *rssJob) getFeed() ([]media.FeedItem, error) {
return items, nil
}
// sort response items
sort.SliceStable(b.Channel.Items, func(i, j int) bool {
return b.Channel.Items[i].PubDate.After(b.Channel.Items[j].PubDate.Time)
})
// process feed items
for p, i := range b.Channel.Items {
// ignore items

View File

@@ -11,22 +11,20 @@ import (
)
type Client struct {
cron *cron.Cron
cache *cache.Client
cacheFiltersHash string
pvrs map[string]pvr.PVR
cron *cron.Cron
cache *cache.Client
pvrs map[string]pvr.PVR
log zerolog.Logger
}
func New(c Config, cc *cache.Client, cfh string, pvrs map[string]pvr.PVR) *Client {
func New(c Config, cc *cache.Client, pvrs map[string]pvr.PVR) *Client {
return &Client{
cron: cron.New(cron.WithChain(
cron.Recover(cron.DefaultLogger),
)),
cache: cc,
cacheFiltersHash: cfh,
pvrs: pvrs,
cache: cc,
pvrs: pvrs,
log: logger.New(c.Verbosity).With().Logger(),
}