Add tag support to Sonarr/Radarr requests
This commit is contained in:
@@ -183,6 +183,12 @@ func (c *Client) AddMediaItem(item *media.Item, opts ...nabarr.PvrOption) error
|
||||
return fmt.Errorf("converting tvdb id to int: %q", item.TvdbId)
|
||||
}
|
||||
|
||||
// prepare tags
|
||||
tags := []string{}
|
||||
if o.Tag != "" {
|
||||
tags = []string{o.Tag}
|
||||
}
|
||||
|
||||
req := addRequest{
|
||||
Title: item.Title,
|
||||
TitleSlug: item.Slug,
|
||||
@@ -190,7 +196,7 @@ func (c *Client) AddMediaItem(item *media.Item, opts ...nabarr.PvrOption) error
|
||||
QualityProfileId: c.qualityProfileId,
|
||||
LanguageProfileId: c.languageProfileId,
|
||||
Images: []string{},
|
||||
Tags: []string{},
|
||||
Tags: tags,
|
||||
Monitored: o.AddMonitored,
|
||||
RootFolderPath: c.rootFolder,
|
||||
AddOptions: addOptions{
|
||||
|
||||
@@ -229,6 +229,9 @@ func (c *Client) queueProcessor(tail state.ShutdownTail) {
|
||||
nabarr.WithAddMonitored(c.addMonitored),
|
||||
nabarr.WithSearchMissing(c.searchMissing),
|
||||
}
|
||||
if c.tag != "" {
|
||||
opts = append(opts, nabarr.WithTag(c.tag))
|
||||
}
|
||||
|
||||
if err := c.AddMediaItem(mediaItem, opts...); err != nil {
|
||||
c.log.Error().
|
||||
|
||||
@@ -29,6 +29,7 @@ type Client struct {
|
||||
searchMissing bool
|
||||
addMonitored bool
|
||||
skipAnime bool
|
||||
tag string
|
||||
|
||||
apiURL string
|
||||
apiHeaders map[string]string
|
||||
@@ -81,6 +82,7 @@ func New(c nabarr.PvrConfig, mode string, m *media.Client, cc *cache.Client) (*C
|
||||
searchMissing: util.BoolOrDefault(c.Options.SearchMissing, true),
|
||||
addMonitored: util.BoolOrDefault(c.Options.AddMonitored, true),
|
||||
skipAnime: util.BoolOrDefault(c.Options.SkipAnime, true),
|
||||
tag: c.Tag,
|
||||
|
||||
cache: cc,
|
||||
cacheTempDuration: c.CacheDuration,
|
||||
|
||||
Reference in New Issue
Block a user