From 81d494ec5c7703ef496c9f8406fa9227c36217b5 Mon Sep 17 00:00:00 2001 From: ze0s <43699394+zze0s@users.noreply.github.com> Date: Sun, 19 Mar 2023 23:35:33 +0100 Subject: [PATCH] fix(feeds): torznab newznab category parsing (#775) --- internal/feed/newznab.go | 2 +- internal/feed/torznab.go | 2 +- pkg/newznab/feed.go | 10 +++++----- pkg/torznab/feed.go | 8 ++++---- pkg/torznab/torznab.go | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/feed/newznab.go b/internal/feed/newznab.go index b47aa84..2455c13 100644 --- a/internal/feed/newznab.go +++ b/internal/feed/newznab.go @@ -168,7 +168,7 @@ func (j *NewznabJob) getFeed(ctx context.Context) ([]newznab.FeedItem, error) { } // only append if we successfully added to cache - items = append(items, i) + items = append(items, *i) } // send to filters diff --git a/internal/feed/torznab.go b/internal/feed/torznab.go index 88125d2..ae97a75 100644 --- a/internal/feed/torznab.go +++ b/internal/feed/torznab.go @@ -232,7 +232,7 @@ func (j *TorznabJob) getFeed(ctx context.Context) ([]torznab.FeedItem, error) { } // only append if we successfully added to cache - items = append(items, i) + items = append(items, *i) } // send to filters diff --git a/pkg/newznab/feed.go b/pkg/newznab/feed.go index 33f92b5..64d13a8 100644 --- a/pkg/newznab/feed.go +++ b/pkg/newznab/feed.go @@ -18,13 +18,13 @@ func (f Feed) Len() int { } type Channel struct { - Title string `xml:"title"` - Items []FeedItem `xml:"item"` + Title string `xml:"title"` + Items []*FeedItem `xml:"item"` } type Response struct { Channel struct { - Items []FeedItem `xml:"item"` + Items []*FeedItem `xml:"item"` } `xml:"channel"` } @@ -63,7 +63,7 @@ type Enclosure struct { Type string `xml:"type,attr"` } -func (f FeedItem) MapCategoriesFromAttr() { +func (f *FeedItem) MapCategoriesFromAttr() { for _, attr := range f.Attributes { if attr.Name == "category" { catId, err := strconv.Atoi(attr.Value) @@ -82,7 +82,7 @@ func (f FeedItem) MapCategoriesFromAttr() { } } -func (f FeedItem) MapCustomCategoriesFromAttr(categories []Category) { +func (f *FeedItem) MapCustomCategoriesFromAttr(categories []Category) { for _, attr := range f.Attributes { if attr.Name == "category" { catId, err := strconv.Atoi(attr.Value) diff --git a/pkg/torznab/feed.go b/pkg/torznab/feed.go index 1cc1820..151ad90 100644 --- a/pkg/torznab/feed.go +++ b/pkg/torznab/feed.go @@ -17,13 +17,13 @@ func (f Feed) Len() int { } type Channel struct { - Title string `xml:"title"` - Items []FeedItem `xml:"item"` + Title string `xml:"title"` + Items []*FeedItem `xml:"item"` } type Response struct { Channel struct { - Items []FeedItem `xml:"item"` + Items []*FeedItem `xml:"item"` } `xml:"channel"` } @@ -55,7 +55,7 @@ type ItemAttr struct { Value string `xml:"value,attr"` } -func (f FeedItem) MapCategories(categories []Category) { +func (f *FeedItem) MapCategories(categories []Category) { for _, category := range f.Category { // less than 10000 it's default categories if category < 10000 { diff --git a/pkg/torznab/torznab.go b/pkg/torznab/torznab.go index 4c5d159..7755257 100644 --- a/pkg/torznab/torznab.go +++ b/pkg/torznab/torznab.go @@ -241,7 +241,7 @@ func (c *client) GetCaps() *Caps { return c.Capabilities } -func (c *client) Search(ctx context.Context, query string) ([]FeedItem, error) { +func (c *client) Search(ctx context.Context, query string) ([]*FeedItem, error) { v := url.Values{} v.Add("q", query) params := v.Encode()