feat: enrich RSS items without IDs via TMDB title search
Some checks failed
Build / build (push) Failing after 13m30s
Some checks failed
Build / build (push) Failing after 13m30s
Items from RSS feeds that have no media ID (tmdb/imdb/tvdb) are now enriched automatically using TMDB's search API. The release name is parsed to extract a clean title and year, then searched against TMDB to retrieve the TMDB ID before validation. - Add media/tmdb package with SearchMovies, SearchShows, and ExtractTitleAndYear (parses torrent release names) - Add EnrichFeedItemWithTmdbId to media.Client, called in rss/process.go before the ID validation switch - Add --run-now flag to nabarr run to trigger all feeds immediately - Wire media.Client through rss.Client and rssJob - Merge feature/add-tag-option (tag support for Sonarr/Radarr) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,9 +26,10 @@ func (c *Client) AddJob(feed feedItem) error {
|
||||
|
||||
// create job
|
||||
job := &rssJob{
|
||||
name: feed.Name,
|
||||
log: l,
|
||||
http: util.NewRetryableHttpClient(60*time.Second, nil, &l),
|
||||
name: feed.Name,
|
||||
log: l,
|
||||
http: util.NewRetryableHttpClient(60*time.Second, nil, &l),
|
||||
mediaClient: c.media,
|
||||
|
||||
url: feed.URL,
|
||||
pvrs: make(map[string]pvr.PVR, 0),
|
||||
@@ -61,6 +62,7 @@ func (c *Client) AddJob(feed feedItem) error {
|
||||
job.jobID = id
|
||||
}
|
||||
|
||||
c.jobs = append(c.jobs, job)
|
||||
job.log.Info().Msg("Initialised")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -128,6 +128,11 @@ func (j *rssJob) getFeed() ([]media.FeedItem, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// attempt to enrich items missing IDs via Trakt title search
|
||||
if j.mediaClient != nil {
|
||||
j.mediaClient.EnrichFeedItemWithTmdbId(&b.Channel.Items[p])
|
||||
}
|
||||
|
||||
// validate item
|
||||
switch {
|
||||
case b.Channel.Items[p].TvdbId != "" && !util.StringSliceContains([]string{"0", "1"}, b.Channel.Items[p].TvdbId):
|
||||
|
||||
13
rss/rss.go
13
rss/rss.go
@@ -10,28 +10,39 @@ import (
|
||||
"github.com/l3uddz/nabarr/cache"
|
||||
"github.com/l3uddz/nabarr/cmd/nabarr/pvr"
|
||||
"github.com/l3uddz/nabarr/logger"
|
||||
"github.com/l3uddz/nabarr/media"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
cron *cron.Cron
|
||||
cache *cache.Client
|
||||
pvrs map[string]pvr.PVR
|
||||
media *media.Client
|
||||
jobs []*rssJob
|
||||
|
||||
log zerolog.Logger
|
||||
}
|
||||
|
||||
func New(c Config, cc *cache.Client, pvrs map[string]pvr.PVR) *Client {
|
||||
func New(c Config, cc *cache.Client, pvrs map[string]pvr.PVR, m *media.Client) *Client {
|
||||
return &Client{
|
||||
cron: cron.New(cron.WithChain(
|
||||
cron.Recover(cron.DefaultLogger),
|
||||
)),
|
||||
cache: cc,
|
||||
pvrs: pvrs,
|
||||
media: m,
|
||||
jobs: make([]*rssJob, 0),
|
||||
|
||||
log: logger.Child(logger.WithLevel(c.Verbosity)),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) RunAll() {
|
||||
for _, job := range c.jobs {
|
||||
job.Run()
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) Start() state.State {
|
||||
c.cron.Start()
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/l3uddz/nabarr/cache"
|
||||
"github.com/l3uddz/nabarr/cmd/nabarr/pvr"
|
||||
"github.com/l3uddz/nabarr/media"
|
||||
)
|
||||
|
||||
type feedItem struct {
|
||||
@@ -26,9 +27,10 @@ type Config struct {
|
||||
}
|
||||
|
||||
type rssJob struct {
|
||||
name string
|
||||
log zerolog.Logger
|
||||
http *http.Client
|
||||
name string
|
||||
log zerolog.Logger
|
||||
http *http.Client
|
||||
mediaClient *media.Client
|
||||
|
||||
url string
|
||||
pvrs map[string]pvr.PVR
|
||||
|
||||
Reference in New Issue
Block a user