fix(feeds): torznab newznab category parsing (#775)

This commit is contained in:
ze0s 2023-03-19 23:35:33 +01:00 committed by GitHub
parent 0d6e23f278
commit 81d494ec5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 12 deletions

View file

@ -168,7 +168,7 @@ func (j *NewznabJob) getFeed(ctx context.Context) ([]newznab.FeedItem, error) {
} }
// only append if we successfully added to cache // only append if we successfully added to cache
items = append(items, i) items = append(items, *i)
} }
// send to filters // send to filters

View file

@ -232,7 +232,7 @@ func (j *TorznabJob) getFeed(ctx context.Context) ([]torznab.FeedItem, error) {
} }
// only append if we successfully added to cache // only append if we successfully added to cache
items = append(items, i) items = append(items, *i)
} }
// send to filters // send to filters

View file

@ -19,12 +19,12 @@ func (f Feed) Len() int {
type Channel struct { type Channel struct {
Title string `xml:"title"` Title string `xml:"title"`
Items []FeedItem `xml:"item"` Items []*FeedItem `xml:"item"`
} }
type Response struct { type Response struct {
Channel struct { Channel struct {
Items []FeedItem `xml:"item"` Items []*FeedItem `xml:"item"`
} `xml:"channel"` } `xml:"channel"`
} }
@ -63,7 +63,7 @@ type Enclosure struct {
Type string `xml:"type,attr"` Type string `xml:"type,attr"`
} }
func (f FeedItem) MapCategoriesFromAttr() { func (f *FeedItem) MapCategoriesFromAttr() {
for _, attr := range f.Attributes { for _, attr := range f.Attributes {
if attr.Name == "category" { if attr.Name == "category" {
catId, err := strconv.Atoi(attr.Value) 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 { for _, attr := range f.Attributes {
if attr.Name == "category" { if attr.Name == "category" {
catId, err := strconv.Atoi(attr.Value) catId, err := strconv.Atoi(attr.Value)

View file

@ -18,12 +18,12 @@ func (f Feed) Len() int {
type Channel struct { type Channel struct {
Title string `xml:"title"` Title string `xml:"title"`
Items []FeedItem `xml:"item"` Items []*FeedItem `xml:"item"`
} }
type Response struct { type Response struct {
Channel struct { Channel struct {
Items []FeedItem `xml:"item"` Items []*FeedItem `xml:"item"`
} `xml:"channel"` } `xml:"channel"`
} }
@ -55,7 +55,7 @@ type ItemAttr struct {
Value string `xml:"value,attr"` Value string `xml:"value,attr"`
} }
func (f FeedItem) MapCategories(categories []Category) { func (f *FeedItem) MapCategories(categories []Category) {
for _, category := range f.Category { for _, category := range f.Category {
// less than 10000 it's default categories // less than 10000 it's default categories
if category < 10000 { if category < 10000 {

View file

@ -241,7 +241,7 @@ func (c *client) GetCaps() *Caps {
return c.Capabilities 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 := url.Values{}
v.Add("q", query) v.Add("q", query)
params := v.Encode() params := v.Encode()