diff --git a/internal/action/lidarr.go b/internal/action/lidarr.go index b5bece5..80354b5 100644 --- a/internal/action/lidarr.go +++ b/internal/action/lidarr.go @@ -43,19 +43,28 @@ func (s *service) lidarr(ctx context.Context, action *domain.Action, release dom cfg.Password = client.Settings.Basic.Password } - arr := lidarr.New(cfg) + externalId := 0 + if client.Settings.ExternalDownloadClientId > 0 { + externalId = client.Settings.ExternalDownloadClientId + } else if action.ExternalDownloadClientID > 0 { + externalId = int(action.ExternalDownloadClientID) + } r := lidarr.Release{ Title: release.TorrentName, + InfoUrl: release.InfoURL, DownloadUrl: release.DownloadURL, MagnetUrl: release.MagnetURI, Size: int64(release.Size), Indexer: release.Indexer, - DownloadProtocol: "torrent", - Protocol: "torrent", + DownloadClientId: externalId, + DownloadProtocol: string(release.Protocol), + Protocol: string(release.Protocol), PublishDate: time.Now().Format(time.RFC3339), } + arr := lidarr.New(cfg) + rejections, err := arr.Push(ctx, r) if err != nil { s.log.Error().Err(err).Msgf("lidarr: failed to push release: %v", r) diff --git a/internal/action/radarr.go b/internal/action/radarr.go index f3aab23..f763bca 100644 --- a/internal/action/radarr.go +++ b/internal/action/radarr.go @@ -42,19 +42,28 @@ func (s *service) radarr(ctx context.Context, action *domain.Action, release dom cfg.Password = client.Settings.Basic.Password } - arr := radarr.New(cfg) + externalId := 0 + if client.Settings.ExternalDownloadClientId > 0 { + externalId = client.Settings.ExternalDownloadClientId + } else if action.ExternalDownloadClientID > 0 { + externalId = int(action.ExternalDownloadClientID) + } r := radarr.Release{ Title: release.TorrentName, + InfoUrl: release.InfoURL, DownloadUrl: release.DownloadURL, MagnetUrl: release.MagnetURI, Size: int64(release.Size), Indexer: release.Indexer, + DownloadClientId: externalId, DownloadProtocol: string(release.Protocol), Protocol: string(release.Protocol), PublishDate: time.Now().Format(time.RFC3339), } + arr := radarr.New(cfg) + rejections, err := arr.Push(ctx, r) if err != nil { return nil, errors.Wrap(err, "radarr failed to push release: %v", r) diff --git a/internal/action/readarr.go b/internal/action/readarr.go index 8f50087..11bbfea 100644 --- a/internal/action/readarr.go +++ b/internal/action/readarr.go @@ -42,19 +42,28 @@ func (s *service) readarr(ctx context.Context, action *domain.Action, release do cfg.Password = client.Settings.Basic.Password } - arr := readarr.New(cfg) + externalId := 0 + if client.Settings.ExternalDownloadClientId > 0 { + externalId = client.Settings.ExternalDownloadClientId + } else if action.ExternalDownloadClientID > 0 { + externalId = int(action.ExternalDownloadClientID) + } r := readarr.Release{ Title: release.TorrentName, + InfoUrl: release.InfoURL, DownloadUrl: release.DownloadURL, MagnetUrl: release.MagnetURI, Size: int64(release.Size), Indexer: release.Indexer, - DownloadProtocol: "torrent", - Protocol: "torrent", + DownloadClientId: externalId, + DownloadProtocol: string(release.Protocol), + Protocol: string(release.Protocol), PublishDate: time.Now().Format(time.RFC3339), } + arr := readarr.New(cfg) + rejections, err := arr.Push(ctx, r) if err != nil { return nil, errors.Wrap(err, "readarr: failed to push release: %v", r) diff --git a/internal/action/run.go b/internal/action/run.go index eadde96..134885c 100644 --- a/internal/action/run.go +++ b/internal/action/run.go @@ -92,8 +92,7 @@ func (s *service) RunAction(ctx context.Context, action *domain.Action, release rejections, err = s.sabnzbd(ctx, action, *release) default: - s.log.Warn().Msgf("unsupported action type: %v", action.Type) - return rejections, err + return nil, errors.New("unsupported action type: %s", action.Type) } payload := &domain.NotificationPayload{ diff --git a/internal/action/sonarr.go b/internal/action/sonarr.go index cd405b1..41bc4ac 100644 --- a/internal/action/sonarr.go +++ b/internal/action/sonarr.go @@ -42,19 +42,28 @@ func (s *service) sonarr(ctx context.Context, action *domain.Action, release dom cfg.Password = client.Settings.Basic.Password } - arr := sonarr.New(cfg) + externalId := 0 + if client.Settings.ExternalDownloadClientId > 0 { + externalId = client.Settings.ExternalDownloadClientId + } else if action.ExternalDownloadClientID > 0 { + externalId = int(action.ExternalDownloadClientID) + } r := sonarr.Release{ Title: release.TorrentName, + InfoUrl: release.InfoURL, DownloadUrl: release.DownloadURL, MagnetUrl: release.MagnetURI, Size: int64(release.Size), Indexer: release.Indexer, + DownloadClientId: externalId, DownloadProtocol: string(release.Protocol), Protocol: string(release.Protocol), PublishDate: time.Now().Format(time.RFC3339), } + arr := sonarr.New(cfg) + rejections, err := arr.Push(ctx, r) if err != nil { return nil, errors.Wrap(err, "sonarr: failed to push release: %v", r) diff --git a/internal/action/whisparr.go b/internal/action/whisparr.go index 19daaf8..5a1ac6a 100644 --- a/internal/action/whisparr.go +++ b/internal/action/whisparr.go @@ -42,19 +42,28 @@ func (s *service) whisparr(ctx context.Context, action *domain.Action, release d cfg.Password = client.Settings.Basic.Password } - arr := whisparr.New(cfg) + externalId := 0 + if client.Settings.ExternalDownloadClientId > 0 { + externalId = client.Settings.ExternalDownloadClientId + } else if action.ExternalDownloadClientID > 0 { + externalId = int(action.ExternalDownloadClientID) + } r := whisparr.Release{ Title: release.TorrentName, + InfoUrl: release.InfoURL, DownloadUrl: release.DownloadURL, MagnetUrl: release.MagnetURI, Size: int64(release.Size), Indexer: release.Indexer, - DownloadProtocol: "torrent", - Protocol: "torrent", + DownloadClientId: externalId, + DownloadProtocol: string(release.Protocol), + Protocol: string(release.Protocol), PublishDate: time.Now().Format(time.RFC3339), } + arr := whisparr.New(cfg) + rejections, err := arr.Push(ctx, r) if err != nil { return nil, errors.Wrap(err, "whisparr: failed to push release: %v", r) diff --git a/internal/database/action.go b/internal/database/action.go index c04f36a..0ebfd2c 100644 --- a/internal/database/action.go +++ b/internal/database/action.go @@ -89,6 +89,7 @@ func (r *ActionRepo) findByFilterID(ctx context.Context, tx *Tx, filterID int) ( "webhook_type", "webhook_method", "webhook_data", + "external_client_id", "client_id", ). From("action"). @@ -114,10 +115,10 @@ func (r *ActionRepo) findByFilterID(ctx context.Context, tx *Tx, filterID int) ( var limitUl, limitDl, limitSeedTime sql.NullInt64 var limitRatio sql.NullFloat64 - var clientID sql.NullInt32 + var externalClientID, clientID sql.NullInt32 var paused, ignoreRules sql.NullBool - if err := rows.Scan(&a.ID, &a.Name, &a.Type, &a.Enabled, &execCmd, &execArgs, &watchFolder, &category, &tags, &label, &savePath, &paused, &ignoreRules, &a.SkipHashCheck, &contentLayout, &limitDl, &limitUl, &limitRatio, &limitSeedTime, &a.ReAnnounceSkip, &a.ReAnnounceDelete, &a.ReAnnounceInterval, &a.ReAnnounceMaxAttempts, &webhookHost, &webhookType, &webhookMethod, &webhookData, &clientID); err != nil { + if err := rows.Scan(&a.ID, &a.Name, &a.Type, &a.Enabled, &execCmd, &execArgs, &watchFolder, &category, &tags, &label, &savePath, &paused, &ignoreRules, &a.SkipHashCheck, &contentLayout, &limitDl, &limitUl, &limitRatio, &limitSeedTime, &a.ReAnnounceSkip, &a.ReAnnounceDelete, &a.ReAnnounceInterval, &a.ReAnnounceMaxAttempts, &webhookHost, &webhookType, &webhookMethod, &webhookData, &externalClientID, &clientID); err != nil { return nil, errors.Wrap(err, "error scanning row") } @@ -142,6 +143,7 @@ func (r *ActionRepo) findByFilterID(ctx context.Context, tx *Tx, filterID int) ( a.WebhookMethod = webhookMethod.String a.WebhookData = webhookData.String + a.ExternalDownloadClientID = externalClientID.Int32 a.ClientID = clientID.Int32 actions = append(actions, &a) @@ -233,6 +235,7 @@ func (r *ActionRepo) List(ctx context.Context) ([]domain.Action, error) { "webhook_type", "webhook_method", "webhook_data", + "external_client_id", "client_id", ). From("action") @@ -256,10 +259,10 @@ func (r *ActionRepo) List(ctx context.Context) ([]domain.Action, error) { var execCmd, execArgs, watchFolder, category, tags, label, savePath, contentLayout, webhookHost, webhookType, webhookMethod, webhookData sql.NullString var limitUl, limitDl, limitSeedTime sql.NullInt64 var limitRatio sql.NullFloat64 - var clientID sql.NullInt32 + var externalClientID, clientID sql.NullInt32 var paused, ignoreRules sql.NullBool - if err := rows.Scan(&a.ID, &a.Name, &a.Type, &a.Enabled, &execCmd, &execArgs, &watchFolder, &category, &tags, &label, &savePath, &paused, &ignoreRules, &a.SkipHashCheck, &contentLayout, &limitDl, &limitUl, &limitRatio, &limitSeedTime, &a.ReAnnounceSkip, &a.ReAnnounceDelete, &a.ReAnnounceInterval, &a.ReAnnounceMaxAttempts, &webhookHost, &webhookType, &webhookMethod, &webhookData, &clientID); err != nil { + if err := rows.Scan(&a.ID, &a.Name, &a.Type, &a.Enabled, &execCmd, &execArgs, &watchFolder, &category, &tags, &label, &savePath, &paused, &ignoreRules, &a.SkipHashCheck, &contentLayout, &limitDl, &limitUl, &limitRatio, &limitSeedTime, &a.ReAnnounceSkip, &a.ReAnnounceDelete, &a.ReAnnounceInterval, &a.ReAnnounceMaxAttempts, &webhookHost, &webhookType, &webhookMethod, &webhookData, &externalClientID, &clientID); err != nil { return nil, errors.Wrap(err, "error scanning row") } @@ -281,6 +284,7 @@ func (r *ActionRepo) List(ctx context.Context) ([]domain.Action, error) { a.WebhookMethod = webhookMethod.String a.WebhookData = webhookData.String + a.ExternalDownloadClientID = externalClientID.Int32 a.ClientID = clientID.Int32 actions = append(actions, a) @@ -323,6 +327,7 @@ func (r *ActionRepo) Get(ctx context.Context, req *domain.GetActionRequest) (*do "webhook_type", "webhook_method", "webhook_data", + "external_client_id", "client_id", "filter_id", ). @@ -348,10 +353,10 @@ func (r *ActionRepo) Get(ctx context.Context, req *domain.GetActionRequest) (*do var execCmd, execArgs, watchFolder, category, tags, label, savePath, contentLayout, webhookHost, webhookType, webhookMethod, webhookData sql.NullString var limitUl, limitDl, limitSeedTime sql.NullInt64 var limitRatio sql.NullFloat64 - var clientID, filterID sql.NullInt32 + var externalClientID, clientID, filterID sql.NullInt32 var paused, ignoreRules sql.NullBool - if err := row.Scan(&a.ID, &a.Name, &a.Type, &a.Enabled, &execCmd, &execArgs, &watchFolder, &category, &tags, &label, &savePath, &paused, &ignoreRules, &a.SkipHashCheck, &contentLayout, &limitDl, &limitUl, &limitRatio, &limitSeedTime, &a.ReAnnounceSkip, &a.ReAnnounceDelete, &a.ReAnnounceInterval, &a.ReAnnounceMaxAttempts, &webhookHost, &webhookType, &webhookMethod, &webhookData, &clientID, &filterID); err != nil { + if err := row.Scan(&a.ID, &a.Name, &a.Type, &a.Enabled, &execCmd, &execArgs, &watchFolder, &category, &tags, &label, &savePath, &paused, &ignoreRules, &a.SkipHashCheck, &contentLayout, &limitDl, &limitUl, &limitRatio, &limitSeedTime, &a.ReAnnounceSkip, &a.ReAnnounceDelete, &a.ReAnnounceInterval, &a.ReAnnounceMaxAttempts, &webhookHost, &webhookType, &webhookMethod, &webhookData, &externalClientID, &clientID, &filterID); err != nil { if errors.Is(err, sql.ErrNoRows) { return nil, domain.ErrRecordNotFound } @@ -380,6 +385,7 @@ func (r *ActionRepo) Get(ctx context.Context, req *domain.GetActionRequest) (*do a.WebhookMethod = webhookMethod.String a.WebhookData = webhookData.String + a.ExternalDownloadClientID = externalClientID.Int32 a.ClientID = clientID.Int32 a.FilterID = int(filterID.Int32) @@ -454,6 +460,7 @@ func (r *ActionRepo) Store(ctx context.Context, action domain.Action) (*domain.A "webhook_type", "webhook_method", "webhook_data", + "external_client_id", "client_id", "filter_id", ). @@ -484,6 +491,7 @@ func (r *ActionRepo) Store(ctx context.Context, action domain.Action) (*domain.A toNullString(action.WebhookType), toNullString(action.WebhookMethod), toNullString(action.WebhookData), + toNullInt32(action.ExternalDownloadClientID), toNullInt32(action.ClientID), toNullInt32(int32(action.FilterID)), ). @@ -532,6 +540,7 @@ func (r *ActionRepo) Update(ctx context.Context, action domain.Action) (*domain. Set("webhook_type", toNullString(action.WebhookType)). Set("webhook_method", toNullString(action.WebhookMethod)). Set("webhook_data", toNullString(action.WebhookData)). + Set("external_client_id", toNullInt32(action.ExternalDownloadClientID)). Set("client_id", toNullInt32(action.ClientID)). Set("filter_id", toNullInt32(int32(action.FilterID))). Where(sq.Eq{"id": action.ID}) @@ -590,6 +599,7 @@ func (r *ActionRepo) StoreFilterActions(ctx context.Context, filterID int64, act Set("webhook_type", toNullString(action.WebhookType)). Set("webhook_method", toNullString(action.WebhookMethod)). Set("webhook_data", toNullString(action.WebhookData)). + Set("external_client_id", toNullInt32(action.ExternalDownloadClientID)). Set("client_id", toNullInt32(action.ClientID)). Set("filter_id", toNullInt64(filterID)). Where(sq.Eq{"id": action.ID}) @@ -635,6 +645,7 @@ func (r *ActionRepo) StoreFilterActions(ctx context.Context, filterID int64, act "webhook_type", "webhook_method", "webhook_data", + "external_client_id", "client_id", "filter_id", ). @@ -665,6 +676,7 @@ func (r *ActionRepo) StoreFilterActions(ctx context.Context, filterID int64, act toNullString(action.WebhookType), toNullString(action.WebhookMethod), toNullString(action.WebhookData), + toNullInt32(action.ExternalDownloadClientID), toNullInt32(action.ClientID), toNullInt64(filterID), ). diff --git a/internal/database/download_client.go b/internal/database/download_client.go index 128df35..c8f0696 100644 --- a/internal/database/download_client.go +++ b/internal/database/download_client.go @@ -176,9 +176,10 @@ func (r *DownloadClientRepo) Store(ctx context.Context, client domain.DownloadCl var err error settings := domain.DownloadClientSettings{ - APIKey: client.Settings.APIKey, - Basic: client.Settings.Basic, - Rules: client.Settings.Rules, + APIKey: client.Settings.APIKey, + Basic: client.Settings.Basic, + Rules: client.Settings.Rules, + ExternalDownloadClientId: client.Settings.ExternalDownloadClientId, } settingsJson, err := json.Marshal(&settings) @@ -214,9 +215,10 @@ func (r *DownloadClientRepo) Update(ctx context.Context, client domain.DownloadC var err error settings := domain.DownloadClientSettings{ - APIKey: client.Settings.APIKey, - Basic: client.Settings.Basic, - Rules: client.Settings.Rules, + APIKey: client.Settings.APIKey, + Basic: client.Settings.Basic, + Rules: client.Settings.Rules, + ExternalDownloadClientId: client.Settings.ExternalDownloadClientId, } settingsJson, err := json.Marshal(&settings) diff --git a/internal/database/postgres_migrate.go b/internal/database/postgres_migrate.go index 07a6d8a..a6ce260 100644 --- a/internal/database/postgres_migrate.go +++ b/internal/database/postgres_migrate.go @@ -204,6 +204,7 @@ CREATE TABLE action webhook_type TEXT, webhook_data TEXT, webhook_headers TEXT[] DEFAULT '{}', + external_client_id INTEGER, client_id INTEGER, filter_id INTEGER, FOREIGN KEY (filter_id) REFERENCES filter (id), @@ -793,5 +794,8 @@ CREATE TABLE feed_cache CREATE INDEX feed_cache_feed_id_key_index ON feed_cache (feed_id, key); +`, + `ALTER TABLE action +ADD COLUMN external_client_id INTEGER; `, } diff --git a/internal/database/sqlite_migrate.go b/internal/database/sqlite_migrate.go index db4a09e..fdde6f7 100644 --- a/internal/database/sqlite_migrate.go +++ b/internal/database/sqlite_migrate.go @@ -204,6 +204,7 @@ CREATE TABLE action webhook_type TEXT, webhook_data TEXT, webhook_headers TEXT[] DEFAULT '{}', + external_client_id INTEGER, client_id INTEGER, filter_id INTEGER, FOREIGN KEY (filter_id) REFERENCES filter (id), @@ -1344,5 +1345,8 @@ CREATE TABLE feed_cache CREATE INDEX feed_cache_feed_id_key_index ON feed_cache (feed_id, key); +`, + `ALTER TABLE action +ADD COLUMN external_client_id INTEGER; `, } diff --git a/internal/domain/action.go b/internal/domain/action.go index 4dd7f13..74dbf13 100644 --- a/internal/domain/action.go +++ b/internal/domain/action.go @@ -23,37 +23,38 @@ type ActionRepo interface { } type Action struct { - ID int `json:"id"` - Name string `json:"name"` - Type ActionType `json:"type"` - Enabled bool `json:"enabled"` - ExecCmd string `json:"exec_cmd,omitempty"` - ExecArgs string `json:"exec_args,omitempty"` - WatchFolder string `json:"watch_folder,omitempty"` - Category string `json:"category,omitempty"` - Tags string `json:"tags,omitempty"` - Label string `json:"label,omitempty"` - SavePath string `json:"save_path,omitempty"` - Paused bool `json:"paused,omitempty"` - IgnoreRules bool `json:"ignore_rules,omitempty"` - SkipHashCheck bool `json:"skip_hash_check,omitempty"` - ContentLayout ActionContentLayout `json:"content_layout,omitempty"` - LimitUploadSpeed int64 `json:"limit_upload_speed,omitempty"` - LimitDownloadSpeed int64 `json:"limit_download_speed,omitempty"` - LimitRatio float64 `json:"limit_ratio,omitempty"` - LimitSeedTime int64 `json:"limit_seed_time,omitempty"` - ReAnnounceSkip bool `json:"reannounce_skip,omitempty"` - ReAnnounceDelete bool `json:"reannounce_delete,omitempty"` - ReAnnounceInterval int64 `json:"reannounce_interval,omitempty"` - ReAnnounceMaxAttempts int64 `json:"reannounce_max_attempts,omitempty"` - WebhookHost string `json:"webhook_host,omitempty"` - WebhookType string `json:"webhook_type,omitempty"` - WebhookMethod string `json:"webhook_method,omitempty"` - WebhookData string `json:"webhook_data,omitempty"` - WebhookHeaders []string `json:"webhook_headers,omitempty"` - FilterID int `json:"filter_id,omitempty"` - ClientID int32 `json:"client_id,omitempty"` - Client *DownloadClient `json:"client,omitempty"` + ID int `json:"id"` + Name string `json:"name"` + Type ActionType `json:"type"` + Enabled bool `json:"enabled"` + ExecCmd string `json:"exec_cmd,omitempty"` + ExecArgs string `json:"exec_args,omitempty"` + WatchFolder string `json:"watch_folder,omitempty"` + Category string `json:"category,omitempty"` + Tags string `json:"tags,omitempty"` + Label string `json:"label,omitempty"` + SavePath string `json:"save_path,omitempty"` + Paused bool `json:"paused,omitempty"` + IgnoreRules bool `json:"ignore_rules,omitempty"` + SkipHashCheck bool `json:"skip_hash_check,omitempty"` + ContentLayout ActionContentLayout `json:"content_layout,omitempty"` + LimitUploadSpeed int64 `json:"limit_upload_speed,omitempty"` + LimitDownloadSpeed int64 `json:"limit_download_speed,omitempty"` + LimitRatio float64 `json:"limit_ratio,omitempty"` + LimitSeedTime int64 `json:"limit_seed_time,omitempty"` + ReAnnounceSkip bool `json:"reannounce_skip,omitempty"` + ReAnnounceDelete bool `json:"reannounce_delete,omitempty"` + ReAnnounceInterval int64 `json:"reannounce_interval,omitempty"` + ReAnnounceMaxAttempts int64 `json:"reannounce_max_attempts,omitempty"` + WebhookHost string `json:"webhook_host,omitempty"` + WebhookType string `json:"webhook_type,omitempty"` + WebhookMethod string `json:"webhook_method,omitempty"` + WebhookData string `json:"webhook_data,omitempty"` + WebhookHeaders []string `json:"webhook_headers,omitempty"` + ExternalDownloadClientID int32 `json:"external_download_client_id,omitempty"` + FilterID int `json:"filter_id,omitempty"` + ClientID int32 `json:"client_id,omitempty"` + Client *DownloadClient `json:"client,omitempty"` } // ParseMacros parse all macros on action diff --git a/internal/domain/client.go b/internal/domain/client.go index 4b68be0..b8ed29a 100644 --- a/internal/domain/client.go +++ b/internal/domain/client.go @@ -41,9 +41,10 @@ type DownloadClientCached struct { } type DownloadClientSettings struct { - APIKey string `json:"apikey,omitempty"` - Basic BasicAuth `json:"basic,omitempty"` - Rules DownloadClientRules `json:"rules,omitempty"` + APIKey string `json:"apikey,omitempty"` + Basic BasicAuth `json:"basic,omitempty"` + Rules DownloadClientRules `json:"rules,omitempty"` + ExternalDownloadClientId int `json:"external_download_client_id,omitempty"` } type DownloadClientRules struct { diff --git a/internal/release/service.go b/internal/release/service.go index 5abc160..be4e31a 100644 --- a/internal/release/service.go +++ b/internal/release/service.go @@ -214,7 +214,7 @@ func (s *service) processFilters(ctx context.Context, filters []domain.Filter, r // run action status, err := s.runAction(ctx, act, release) if err != nil { - l.Error().Stack().Err(err).Msgf("release.Process: error running actions for filter: %s", release.FilterName) + l.Error().Err(err).Msgf("release.Process: error running actions for filter: %s", release.FilterName) //continue } @@ -270,7 +270,7 @@ func (s *service) runAction(ctx context.Context, action *domain.Action, release rejections, err := s.actionSvc.RunAction(ctx, action, release) if err != nil { - s.log.Error().Stack().Err(err).Msgf("release.runAction: error running actions for filter: %s", release.FilterName) + s.log.Error().Err(err).Msgf("release.runAction: error running actions for filter: %s", release.FilterName) status.Status = domain.ReleasePushStatusErr status.Rejections = []string{err.Error()} diff --git a/pkg/lidarr/lidarr.go b/pkg/lidarr/lidarr.go index 591593f..0ba7a81 100644 --- a/pkg/lidarr/lidarr.go +++ b/pkg/lidarr/lidarr.go @@ -62,6 +62,7 @@ func New(config Config) Client { type Release struct { Title string `json:"title"` + InfoUrl string `json:"infoUrl,omitempty"` DownloadUrl string `json:"downloadUrl,omitempty"` MagnetUrl string `json:"magnetUrl,omitempty"` Size int64 `json:"size"` @@ -69,6 +70,7 @@ type Release struct { DownloadProtocol string `json:"downloadProtocol"` Protocol string `json:"protocol"` PublishDate string `json:"publishDate"` + DownloadClientId int `json:"downloadClientId,omitempty"` } type PushResponse struct { @@ -87,7 +89,7 @@ type BadRequestResponse struct { } func (r BadRequestResponse) String() string { - return fmt.Sprintf("[%v: %v] %v: %v - got value: %v", r.Severity, r.ErrorCode, r.PropertyName, r.ErrorMessage, r.AttemptedValue) + return fmt.Sprintf("[%s: %s] %s: %s - got value: %s", r.Severity, r.ErrorCode, r.PropertyName, r.ErrorMessage, r.AttemptedValue) } type SystemStatusResponse struct { diff --git a/pkg/radarr/radarr.go b/pkg/radarr/radarr.go index 91d14e8..21d7c94 100644 --- a/pkg/radarr/radarr.go +++ b/pkg/radarr/radarr.go @@ -61,6 +61,7 @@ func New(config Config) Client { type Release struct { Title string `json:"title"` + InfoUrl string `json:"infoUrl,omitempty"` DownloadUrl string `json:"downloadUrl,omitempty"` MagnetUrl string `json:"magnetUrl,omitempty"` Size int64 `json:"size"` @@ -68,6 +69,7 @@ type Release struct { DownloadProtocol string `json:"downloadProtocol"` Protocol string `json:"protocol"` PublishDate string `json:"publishDate"` + DownloadClientId int `json:"downloadClientId,omitempty"` } type PushResponse struct { @@ -90,7 +92,7 @@ type BadRequestResponse struct { } func (r *BadRequestResponse) String() string { - return fmt.Sprintf("[%v: %v] %v: %v - got value: %v", r.Severity, r.ErrorCode, r.PropertyName, r.ErrorMessage, r.AttemptedValue) + return fmt.Sprintf("[%s: %s] %s: %s - got value: %s", r.Severity, r.ErrorCode, r.PropertyName, r.ErrorMessage, r.AttemptedValue) } func (c *client) Test(ctx context.Context) (*SystemStatusResponse, error) { diff --git a/pkg/readarr/readarr.go b/pkg/readarr/readarr.go index 4eed122..30dd8ac 100644 --- a/pkg/readarr/readarr.go +++ b/pkg/readarr/readarr.go @@ -64,6 +64,7 @@ func New(config Config) Client { type Release struct { Title string `json:"title"` + InfoUrl string `json:"infoUrl,omitempty"` DownloadUrl string `json:"downloadUrl,omitempty"` MagnetUrl string `json:"magnetUrl,omitempty"` Size int64 `json:"size"` @@ -71,6 +72,7 @@ type Release struct { DownloadProtocol string `json:"downloadProtocol"` Protocol string `json:"protocol"` PublishDate string `json:"publishDate"` + DownloadClientId int `json:"downloadClientId,omitempty"` } type PushResponse struct { @@ -89,7 +91,7 @@ type BadRequestResponse struct { } func (r *BadRequestResponse) String() string { - return fmt.Sprintf("[%v: %v] %v: %v - got value: %v", r.Severity, r.ErrorCode, r.PropertyName, r.ErrorMessage, r.AttemptedValue) + return fmt.Sprintf("[%s: %s] %s: %s - got value: %s", r.Severity, r.ErrorCode, r.PropertyName, r.ErrorMessage, r.AttemptedValue) } type SystemStatusResponse struct { diff --git a/pkg/sonarr/sonarr.go b/pkg/sonarr/sonarr.go index 284537f..f19c1ea 100644 --- a/pkg/sonarr/sonarr.go +++ b/pkg/sonarr/sonarr.go @@ -64,6 +64,7 @@ func New(config Config) Client { type Release struct { Title string `json:"title"` + InfoUrl string `json:"infoUrl,omitempty"` DownloadUrl string `json:"downloadUrl,omitempty"` MagnetUrl string `json:"magnetUrl,omitempty"` Size int64 `json:"size"` @@ -71,6 +72,7 @@ type Release struct { DownloadProtocol string `json:"downloadProtocol"` Protocol string `json:"protocol"` PublishDate string `json:"publishDate"` + DownloadClientId int `json:"downloadClientId,omitempty"` } type PushResponse struct { @@ -89,7 +91,7 @@ type BadRequestResponse struct { } func (r *BadRequestResponse) String() string { - return fmt.Sprintf("[%v: %v] %v: %v - got value: %v", r.Severity, r.ErrorCode, r.PropertyName, r.ErrorMessage, r.AttemptedValue) + return fmt.Sprintf("[%s: %s] %s: %s - got value: %s", r.Severity, r.ErrorCode, r.PropertyName, r.ErrorMessage, r.AttemptedValue) } type SystemStatusResponse struct { diff --git a/pkg/whisparr/whisparr.go b/pkg/whisparr/whisparr.go index 7091bc2..f60d2b7 100644 --- a/pkg/whisparr/whisparr.go +++ b/pkg/whisparr/whisparr.go @@ -60,6 +60,7 @@ func New(config Config) Client { type Release struct { Title string `json:"title"` + InfoUrl string `json:"infoUrl,omitempty"` DownloadUrl string `json:"downloadUrl,omitempty"` MagnetUrl string `json:"magnetUrl,omitempty"` Size int64 `json:"size"` @@ -67,6 +68,7 @@ type Release struct { DownloadProtocol string `json:"downloadProtocol"` Protocol string `json:"protocol"` PublishDate string `json:"publishDate"` + DownloadClientId int `json:"downloadClientId,omitempty"` } type PushResponse struct { diff --git a/web/src/forms/settings/DownloadClientForms.tsx b/web/src/forms/settings/DownloadClientForms.tsx index 82452cb..b8af57e 100644 --- a/web/src/forms/settings/DownloadClientForms.tsx +++ b/web/src/forms/settings/DownloadClientForms.tsx @@ -116,6 +116,8 @@ function FormFieldsArr() { )} + +

Specify what client the arr should use by default. Can be overridden per filter action. You can find the id in the arr by looking at the network responses for download clients.

} /> ); } diff --git a/web/src/screens/filters/Action.tsx b/web/src/screens/filters/Action.tsx index c170606..6251ac1 100644 --- a/web/src/screens/filters/Action.tsx +++ b/web/src/screens/filters/Action.tsx @@ -71,6 +71,7 @@ export function FilterActions({ filter, values }: FilterActionsProps) { webhook_method: "", webhook_data: "", webhook_headers: [], + external_download_client_id: 0, client_id: 0 }; @@ -542,6 +543,11 @@ const TypeForm = ({ action, idx, clients }: TypeFormProps) => { action={action} clients={clients} /> + Override Download client Id from the one set in Clients. Useful if you have multiple clients inside the arr.

} + /> ); case "SABNZBD": diff --git a/web/src/types/Download.d.ts b/web/src/types/Download.d.ts index e01c96c..bf041c2 100644 --- a/web/src/types/Download.d.ts +++ b/web/src/types/Download.d.ts @@ -45,6 +45,7 @@ interface DownloadClientSettings { apikey?: string; basic?: DownloadClientBasicAuth; rules?: DownloadClientRules; + external_download_client_id?: number; } interface DownloadClient { diff --git a/web/src/types/Filter.d.ts b/web/src/types/Filter.d.ts index 39ac4ae..d7cbba7 100644 --- a/web/src/types/Filter.d.ts +++ b/web/src/types/Filter.d.ts @@ -102,8 +102,9 @@ interface Action { webhook_method: string; webhook_data: string, webhook_headers: string[]; - filter_id?: number; + external_download_client_id?: number; client_id?: number; + filter_id?: number; } type ActionContentLayout = "ORIGINAL" | "SUBFOLDER_CREATE" | "SUBFOLDER_NONE";