misc: rss and media changes (#27)

* refactor: tweak rss processing

* media: override trakt network with tvdb network if trakts is empty

* media: dont merge tvdb language with trakt language

* media: resolve issue with imdb ids
This commit is contained in:
l3uddz
2021-03-05 22:35:16 +00:00
committed by GitHub
parent c3ab8eda6e
commit 5091d78acf
8 changed files with 64 additions and 9 deletions

View File

@@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"github.com/l3uddz/nabarr/media/trakt"
"github.com/l3uddz/nabarr/util"
"strconv"
)
@@ -64,7 +63,11 @@ func (c *Client) GetShowInfo(item *FeedItem) (*Item, error) {
Msg("Item was not found on tvdb")
} else if ti != nil {
mi.Tvdb = *ti
mi.Languages = util.StringSliceMergeUnique(mi.Languages, []string{ti.Language})
// merge with trakt data
if mi.Network == "" {
mi.Network = ti.Network
}
}
return mi, nil

View File

@@ -4,7 +4,9 @@ import (
"encoding/xml"
"github.com/l3uddz/nabarr/media/omdb"
"github.com/l3uddz/nabarr/media/tvdb"
"github.com/l3uddz/nabarr/util"
"github.com/pkg/errors"
"strings"
"time"
)
@@ -80,11 +82,11 @@ type FeedItem struct {
func (f *FeedItem) GetProviderData() (string, string) {
switch {
case f.TvdbId != "" && f.TvdbId != "0":
case f.TvdbId != "" && !util.StringSliceContains([]string{"0", "1"}, f.TvdbId):
return "tvdb", f.TvdbId
case f.TmdbId != "" && f.TmdbId != "0":
case f.TmdbId != "" && !util.StringSliceContains([]string{"0", "1"}, f.TmdbId):
return "tmdb", f.TmdbId
case f.ImdbId != "":
case f.ImdbId != "" && strings.HasPrefix(f.ImdbId, "tt"):
return "imdb", f.ImdbId
}
return "", ""

View File

@@ -46,6 +46,7 @@ func (c *Client) GetItem(tvdbId string) (*Item, error) {
return &Item{
Runtime: util.Atoi(b.Data.Runtime, 0),
Language: b.Data.Language,
Network: b.Data.Network,
Genre: b.Data.Genre,
AirsDayOfWeek: b.Data.AirsDayOfWeek,
SiteRating: b.Data.SiteRating,

View File

@@ -35,6 +35,7 @@ type lookupResponse struct {
type Item struct {
Runtime int `json:"Runtime,omitempty"`
Language string `json:"Language,omitempty"`
Network string `json:"Network,omitempty"`
Genre []string `json:"Genre,omitempty"`
AirsDayOfWeek string `json:"AirsDayOfWeek,omitempty"`
SiteRating float64 `json:"SiteRating,omitempty"`