feat(downloadclient): set downloadClientId for arr clients (#1081)

feat(downloadclient): arrs set downloadClientId
This commit is contained in:
ze0s 2023-09-03 15:34:55 +02:00 committed by GitHub
parent 1bfbe38335
commit 0d3e10f094
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 154 additions and 66 deletions

View file

@ -43,19 +43,28 @@ func (s *service) lidarr(ctx context.Context, action *domain.Action, release dom
cfg.Password = client.Settings.Basic.Password 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{ r := lidarr.Release{
Title: release.TorrentName, Title: release.TorrentName,
InfoUrl: release.InfoURL,
DownloadUrl: release.DownloadURL, DownloadUrl: release.DownloadURL,
MagnetUrl: release.MagnetURI, MagnetUrl: release.MagnetURI,
Size: int64(release.Size), Size: int64(release.Size),
Indexer: release.Indexer, Indexer: release.Indexer,
DownloadProtocol: "torrent", DownloadClientId: externalId,
Protocol: "torrent", DownloadProtocol: string(release.Protocol),
Protocol: string(release.Protocol),
PublishDate: time.Now().Format(time.RFC3339), PublishDate: time.Now().Format(time.RFC3339),
} }
arr := lidarr.New(cfg)
rejections, err := arr.Push(ctx, r) rejections, err := arr.Push(ctx, r)
if err != nil { if err != nil {
s.log.Error().Err(err).Msgf("lidarr: failed to push release: %v", r) s.log.Error().Err(err).Msgf("lidarr: failed to push release: %v", r)

View file

@ -42,19 +42,28 @@ func (s *service) radarr(ctx context.Context, action *domain.Action, release dom
cfg.Password = client.Settings.Basic.Password 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{ r := radarr.Release{
Title: release.TorrentName, Title: release.TorrentName,
InfoUrl: release.InfoURL,
DownloadUrl: release.DownloadURL, DownloadUrl: release.DownloadURL,
MagnetUrl: release.MagnetURI, MagnetUrl: release.MagnetURI,
Size: int64(release.Size), Size: int64(release.Size),
Indexer: release.Indexer, Indexer: release.Indexer,
DownloadClientId: externalId,
DownloadProtocol: string(release.Protocol), DownloadProtocol: string(release.Protocol),
Protocol: string(release.Protocol), Protocol: string(release.Protocol),
PublishDate: time.Now().Format(time.RFC3339), PublishDate: time.Now().Format(time.RFC3339),
} }
arr := radarr.New(cfg)
rejections, err := arr.Push(ctx, r) rejections, err := arr.Push(ctx, r)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "radarr failed to push release: %v", r) return nil, errors.Wrap(err, "radarr failed to push release: %v", r)

View file

@ -42,19 +42,28 @@ func (s *service) readarr(ctx context.Context, action *domain.Action, release do
cfg.Password = client.Settings.Basic.Password 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{ r := readarr.Release{
Title: release.TorrentName, Title: release.TorrentName,
InfoUrl: release.InfoURL,
DownloadUrl: release.DownloadURL, DownloadUrl: release.DownloadURL,
MagnetUrl: release.MagnetURI, MagnetUrl: release.MagnetURI,
Size: int64(release.Size), Size: int64(release.Size),
Indexer: release.Indexer, Indexer: release.Indexer,
DownloadProtocol: "torrent", DownloadClientId: externalId,
Protocol: "torrent", DownloadProtocol: string(release.Protocol),
Protocol: string(release.Protocol),
PublishDate: time.Now().Format(time.RFC3339), PublishDate: time.Now().Format(time.RFC3339),
} }
arr := readarr.New(cfg)
rejections, err := arr.Push(ctx, r) rejections, err := arr.Push(ctx, r)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "readarr: failed to push release: %v", r) return nil, errors.Wrap(err, "readarr: failed to push release: %v", r)

View file

@ -92,8 +92,7 @@ func (s *service) RunAction(ctx context.Context, action *domain.Action, release
rejections, err = s.sabnzbd(ctx, action, *release) rejections, err = s.sabnzbd(ctx, action, *release)
default: default:
s.log.Warn().Msgf("unsupported action type: %v", action.Type) return nil, errors.New("unsupported action type: %s", action.Type)
return rejections, err
} }
payload := &domain.NotificationPayload{ payload := &domain.NotificationPayload{

View file

@ -42,19 +42,28 @@ func (s *service) sonarr(ctx context.Context, action *domain.Action, release dom
cfg.Password = client.Settings.Basic.Password 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{ r := sonarr.Release{
Title: release.TorrentName, Title: release.TorrentName,
InfoUrl: release.InfoURL,
DownloadUrl: release.DownloadURL, DownloadUrl: release.DownloadURL,
MagnetUrl: release.MagnetURI, MagnetUrl: release.MagnetURI,
Size: int64(release.Size), Size: int64(release.Size),
Indexer: release.Indexer, Indexer: release.Indexer,
DownloadClientId: externalId,
DownloadProtocol: string(release.Protocol), DownloadProtocol: string(release.Protocol),
Protocol: string(release.Protocol), Protocol: string(release.Protocol),
PublishDate: time.Now().Format(time.RFC3339), PublishDate: time.Now().Format(time.RFC3339),
} }
arr := sonarr.New(cfg)
rejections, err := arr.Push(ctx, r) rejections, err := arr.Push(ctx, r)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "sonarr: failed to push release: %v", r) return nil, errors.Wrap(err, "sonarr: failed to push release: %v", r)

View file

@ -42,19 +42,28 @@ func (s *service) whisparr(ctx context.Context, action *domain.Action, release d
cfg.Password = client.Settings.Basic.Password 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{ r := whisparr.Release{
Title: release.TorrentName, Title: release.TorrentName,
InfoUrl: release.InfoURL,
DownloadUrl: release.DownloadURL, DownloadUrl: release.DownloadURL,
MagnetUrl: release.MagnetURI, MagnetUrl: release.MagnetURI,
Size: int64(release.Size), Size: int64(release.Size),
Indexer: release.Indexer, Indexer: release.Indexer,
DownloadProtocol: "torrent", DownloadClientId: externalId,
Protocol: "torrent", DownloadProtocol: string(release.Protocol),
Protocol: string(release.Protocol),
PublishDate: time.Now().Format(time.RFC3339), PublishDate: time.Now().Format(time.RFC3339),
} }
arr := whisparr.New(cfg)
rejections, err := arr.Push(ctx, r) rejections, err := arr.Push(ctx, r)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "whisparr: failed to push release: %v", r) return nil, errors.Wrap(err, "whisparr: failed to push release: %v", r)

View file

@ -89,6 +89,7 @@ func (r *ActionRepo) findByFilterID(ctx context.Context, tx *Tx, filterID int) (
"webhook_type", "webhook_type",
"webhook_method", "webhook_method",
"webhook_data", "webhook_data",
"external_client_id",
"client_id", "client_id",
). ).
From("action"). From("action").
@ -114,10 +115,10 @@ func (r *ActionRepo) findByFilterID(ctx context.Context, tx *Tx, filterID int) (
var limitUl, limitDl, limitSeedTime sql.NullInt64 var limitUl, limitDl, limitSeedTime sql.NullInt64
var limitRatio sql.NullFloat64 var limitRatio sql.NullFloat64
var clientID sql.NullInt32 var externalClientID, clientID sql.NullInt32
var paused, ignoreRules sql.NullBool 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") 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.WebhookMethod = webhookMethod.String
a.WebhookData = webhookData.String a.WebhookData = webhookData.String
a.ExternalDownloadClientID = externalClientID.Int32
a.ClientID = clientID.Int32 a.ClientID = clientID.Int32
actions = append(actions, &a) actions = append(actions, &a)
@ -233,6 +235,7 @@ func (r *ActionRepo) List(ctx context.Context) ([]domain.Action, error) {
"webhook_type", "webhook_type",
"webhook_method", "webhook_method",
"webhook_data", "webhook_data",
"external_client_id",
"client_id", "client_id",
). ).
From("action") 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 execCmd, execArgs, watchFolder, category, tags, label, savePath, contentLayout, webhookHost, webhookType, webhookMethod, webhookData sql.NullString
var limitUl, limitDl, limitSeedTime sql.NullInt64 var limitUl, limitDl, limitSeedTime sql.NullInt64
var limitRatio sql.NullFloat64 var limitRatio sql.NullFloat64
var clientID sql.NullInt32 var externalClientID, clientID sql.NullInt32
var paused, ignoreRules sql.NullBool 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") 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.WebhookMethod = webhookMethod.String
a.WebhookData = webhookData.String a.WebhookData = webhookData.String
a.ExternalDownloadClientID = externalClientID.Int32
a.ClientID = clientID.Int32 a.ClientID = clientID.Int32
actions = append(actions, a) actions = append(actions, a)
@ -323,6 +327,7 @@ func (r *ActionRepo) Get(ctx context.Context, req *domain.GetActionRequest) (*do
"webhook_type", "webhook_type",
"webhook_method", "webhook_method",
"webhook_data", "webhook_data",
"external_client_id",
"client_id", "client_id",
"filter_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 execCmd, execArgs, watchFolder, category, tags, label, savePath, contentLayout, webhookHost, webhookType, webhookMethod, webhookData sql.NullString
var limitUl, limitDl, limitSeedTime sql.NullInt64 var limitUl, limitDl, limitSeedTime sql.NullInt64
var limitRatio sql.NullFloat64 var limitRatio sql.NullFloat64
var clientID, filterID sql.NullInt32 var externalClientID, clientID, filterID sql.NullInt32
var paused, ignoreRules sql.NullBool 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) { if errors.Is(err, sql.ErrNoRows) {
return nil, domain.ErrRecordNotFound return nil, domain.ErrRecordNotFound
} }
@ -380,6 +385,7 @@ func (r *ActionRepo) Get(ctx context.Context, req *domain.GetActionRequest) (*do
a.WebhookMethod = webhookMethod.String a.WebhookMethod = webhookMethod.String
a.WebhookData = webhookData.String a.WebhookData = webhookData.String
a.ExternalDownloadClientID = externalClientID.Int32
a.ClientID = clientID.Int32 a.ClientID = clientID.Int32
a.FilterID = int(filterID.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_type",
"webhook_method", "webhook_method",
"webhook_data", "webhook_data",
"external_client_id",
"client_id", "client_id",
"filter_id", "filter_id",
). ).
@ -484,6 +491,7 @@ func (r *ActionRepo) Store(ctx context.Context, action domain.Action) (*domain.A
toNullString(action.WebhookType), toNullString(action.WebhookType),
toNullString(action.WebhookMethod), toNullString(action.WebhookMethod),
toNullString(action.WebhookData), toNullString(action.WebhookData),
toNullInt32(action.ExternalDownloadClientID),
toNullInt32(action.ClientID), toNullInt32(action.ClientID),
toNullInt32(int32(action.FilterID)), 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_type", toNullString(action.WebhookType)).
Set("webhook_method", toNullString(action.WebhookMethod)). Set("webhook_method", toNullString(action.WebhookMethod)).
Set("webhook_data", toNullString(action.WebhookData)). Set("webhook_data", toNullString(action.WebhookData)).
Set("external_client_id", toNullInt32(action.ExternalDownloadClientID)).
Set("client_id", toNullInt32(action.ClientID)). Set("client_id", toNullInt32(action.ClientID)).
Set("filter_id", toNullInt32(int32(action.FilterID))). Set("filter_id", toNullInt32(int32(action.FilterID))).
Where(sq.Eq{"id": action.ID}) 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_type", toNullString(action.WebhookType)).
Set("webhook_method", toNullString(action.WebhookMethod)). Set("webhook_method", toNullString(action.WebhookMethod)).
Set("webhook_data", toNullString(action.WebhookData)). Set("webhook_data", toNullString(action.WebhookData)).
Set("external_client_id", toNullInt32(action.ExternalDownloadClientID)).
Set("client_id", toNullInt32(action.ClientID)). Set("client_id", toNullInt32(action.ClientID)).
Set("filter_id", toNullInt64(filterID)). Set("filter_id", toNullInt64(filterID)).
Where(sq.Eq{"id": action.ID}) Where(sq.Eq{"id": action.ID})
@ -635,6 +645,7 @@ func (r *ActionRepo) StoreFilterActions(ctx context.Context, filterID int64, act
"webhook_type", "webhook_type",
"webhook_method", "webhook_method",
"webhook_data", "webhook_data",
"external_client_id",
"client_id", "client_id",
"filter_id", "filter_id",
). ).
@ -665,6 +676,7 @@ func (r *ActionRepo) StoreFilterActions(ctx context.Context, filterID int64, act
toNullString(action.WebhookType), toNullString(action.WebhookType),
toNullString(action.WebhookMethod), toNullString(action.WebhookMethod),
toNullString(action.WebhookData), toNullString(action.WebhookData),
toNullInt32(action.ExternalDownloadClientID),
toNullInt32(action.ClientID), toNullInt32(action.ClientID),
toNullInt64(filterID), toNullInt64(filterID),
). ).

View file

@ -179,6 +179,7 @@ func (r *DownloadClientRepo) Store(ctx context.Context, client domain.DownloadCl
APIKey: client.Settings.APIKey, APIKey: client.Settings.APIKey,
Basic: client.Settings.Basic, Basic: client.Settings.Basic,
Rules: client.Settings.Rules, Rules: client.Settings.Rules,
ExternalDownloadClientId: client.Settings.ExternalDownloadClientId,
} }
settingsJson, err := json.Marshal(&settings) settingsJson, err := json.Marshal(&settings)
@ -217,6 +218,7 @@ func (r *DownloadClientRepo) Update(ctx context.Context, client domain.DownloadC
APIKey: client.Settings.APIKey, APIKey: client.Settings.APIKey,
Basic: client.Settings.Basic, Basic: client.Settings.Basic,
Rules: client.Settings.Rules, Rules: client.Settings.Rules,
ExternalDownloadClientId: client.Settings.ExternalDownloadClientId,
} }
settingsJson, err := json.Marshal(&settings) settingsJson, err := json.Marshal(&settings)

View file

@ -204,6 +204,7 @@ CREATE TABLE action
webhook_type TEXT, webhook_type TEXT,
webhook_data TEXT, webhook_data TEXT,
webhook_headers TEXT[] DEFAULT '{}', webhook_headers TEXT[] DEFAULT '{}',
external_client_id INTEGER,
client_id INTEGER, client_id INTEGER,
filter_id INTEGER, filter_id INTEGER,
FOREIGN KEY (filter_id) REFERENCES filter (id), FOREIGN KEY (filter_id) REFERENCES filter (id),
@ -793,5 +794,8 @@ CREATE TABLE feed_cache
CREATE INDEX feed_cache_feed_id_key_index CREATE INDEX feed_cache_feed_id_key_index
ON feed_cache (feed_id, key); ON feed_cache (feed_id, key);
`,
`ALTER TABLE action
ADD COLUMN external_client_id INTEGER;
`, `,
} }

View file

@ -204,6 +204,7 @@ CREATE TABLE action
webhook_type TEXT, webhook_type TEXT,
webhook_data TEXT, webhook_data TEXT,
webhook_headers TEXT[] DEFAULT '{}', webhook_headers TEXT[] DEFAULT '{}',
external_client_id INTEGER,
client_id INTEGER, client_id INTEGER,
filter_id INTEGER, filter_id INTEGER,
FOREIGN KEY (filter_id) REFERENCES filter (id), FOREIGN KEY (filter_id) REFERENCES filter (id),
@ -1344,5 +1345,8 @@ CREATE TABLE feed_cache
CREATE INDEX feed_cache_feed_id_key_index CREATE INDEX feed_cache_feed_id_key_index
ON feed_cache (feed_id, key); ON feed_cache (feed_id, key);
`,
`ALTER TABLE action
ADD COLUMN external_client_id INTEGER;
`, `,
} }

View file

@ -51,6 +51,7 @@ type Action struct {
WebhookMethod string `json:"webhook_method,omitempty"` WebhookMethod string `json:"webhook_method,omitempty"`
WebhookData string `json:"webhook_data,omitempty"` WebhookData string `json:"webhook_data,omitempty"`
WebhookHeaders []string `json:"webhook_headers,omitempty"` WebhookHeaders []string `json:"webhook_headers,omitempty"`
ExternalDownloadClientID int32 `json:"external_download_client_id,omitempty"`
FilterID int `json:"filter_id,omitempty"` FilterID int `json:"filter_id,omitempty"`
ClientID int32 `json:"client_id,omitempty"` ClientID int32 `json:"client_id,omitempty"`
Client *DownloadClient `json:"client,omitempty"` Client *DownloadClient `json:"client,omitempty"`

View file

@ -44,6 +44,7 @@ type DownloadClientSettings struct {
APIKey string `json:"apikey,omitempty"` APIKey string `json:"apikey,omitempty"`
Basic BasicAuth `json:"basic,omitempty"` Basic BasicAuth `json:"basic,omitempty"`
Rules DownloadClientRules `json:"rules,omitempty"` Rules DownloadClientRules `json:"rules,omitempty"`
ExternalDownloadClientId int `json:"external_download_client_id,omitempty"`
} }
type DownloadClientRules struct { type DownloadClientRules struct {

View file

@ -214,7 +214,7 @@ func (s *service) processFilters(ctx context.Context, filters []domain.Filter, r
// run action // run action
status, err := s.runAction(ctx, act, release) status, err := s.runAction(ctx, act, release)
if err != nil { 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 //continue
} }
@ -270,7 +270,7 @@ func (s *service) runAction(ctx context.Context, action *domain.Action, release
rejections, err := s.actionSvc.RunAction(ctx, action, release) rejections, err := s.actionSvc.RunAction(ctx, action, release)
if err != nil { 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.Status = domain.ReleasePushStatusErr
status.Rejections = []string{err.Error()} status.Rejections = []string{err.Error()}

View file

@ -62,6 +62,7 @@ func New(config Config) Client {
type Release struct { type Release struct {
Title string `json:"title"` Title string `json:"title"`
InfoUrl string `json:"infoUrl,omitempty"`
DownloadUrl string `json:"downloadUrl,omitempty"` DownloadUrl string `json:"downloadUrl,omitempty"`
MagnetUrl string `json:"magnetUrl,omitempty"` MagnetUrl string `json:"magnetUrl,omitempty"`
Size int64 `json:"size"` Size int64 `json:"size"`
@ -69,6 +70,7 @@ type Release struct {
DownloadProtocol string `json:"downloadProtocol"` DownloadProtocol string `json:"downloadProtocol"`
Protocol string `json:"protocol"` Protocol string `json:"protocol"`
PublishDate string `json:"publishDate"` PublishDate string `json:"publishDate"`
DownloadClientId int `json:"downloadClientId,omitempty"`
} }
type PushResponse struct { type PushResponse struct {
@ -87,7 +89,7 @@ type BadRequestResponse struct {
} }
func (r BadRequestResponse) String() string { 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 { type SystemStatusResponse struct {

View file

@ -61,6 +61,7 @@ func New(config Config) Client {
type Release struct { type Release struct {
Title string `json:"title"` Title string `json:"title"`
InfoUrl string `json:"infoUrl,omitempty"`
DownloadUrl string `json:"downloadUrl,omitempty"` DownloadUrl string `json:"downloadUrl,omitempty"`
MagnetUrl string `json:"magnetUrl,omitempty"` MagnetUrl string `json:"magnetUrl,omitempty"`
Size int64 `json:"size"` Size int64 `json:"size"`
@ -68,6 +69,7 @@ type Release struct {
DownloadProtocol string `json:"downloadProtocol"` DownloadProtocol string `json:"downloadProtocol"`
Protocol string `json:"protocol"` Protocol string `json:"protocol"`
PublishDate string `json:"publishDate"` PublishDate string `json:"publishDate"`
DownloadClientId int `json:"downloadClientId,omitempty"`
} }
type PushResponse struct { type PushResponse struct {
@ -90,7 +92,7 @@ type BadRequestResponse struct {
} }
func (r *BadRequestResponse) String() string { 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) { func (c *client) Test(ctx context.Context) (*SystemStatusResponse, error) {

View file

@ -64,6 +64,7 @@ func New(config Config) Client {
type Release struct { type Release struct {
Title string `json:"title"` Title string `json:"title"`
InfoUrl string `json:"infoUrl,omitempty"`
DownloadUrl string `json:"downloadUrl,omitempty"` DownloadUrl string `json:"downloadUrl,omitempty"`
MagnetUrl string `json:"magnetUrl,omitempty"` MagnetUrl string `json:"magnetUrl,omitempty"`
Size int64 `json:"size"` Size int64 `json:"size"`
@ -71,6 +72,7 @@ type Release struct {
DownloadProtocol string `json:"downloadProtocol"` DownloadProtocol string `json:"downloadProtocol"`
Protocol string `json:"protocol"` Protocol string `json:"protocol"`
PublishDate string `json:"publishDate"` PublishDate string `json:"publishDate"`
DownloadClientId int `json:"downloadClientId,omitempty"`
} }
type PushResponse struct { type PushResponse struct {
@ -89,7 +91,7 @@ type BadRequestResponse struct {
} }
func (r *BadRequestResponse) String() string { 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 { type SystemStatusResponse struct {

View file

@ -64,6 +64,7 @@ func New(config Config) Client {
type Release struct { type Release struct {
Title string `json:"title"` Title string `json:"title"`
InfoUrl string `json:"infoUrl,omitempty"`
DownloadUrl string `json:"downloadUrl,omitempty"` DownloadUrl string `json:"downloadUrl,omitempty"`
MagnetUrl string `json:"magnetUrl,omitempty"` MagnetUrl string `json:"magnetUrl,omitempty"`
Size int64 `json:"size"` Size int64 `json:"size"`
@ -71,6 +72,7 @@ type Release struct {
DownloadProtocol string `json:"downloadProtocol"` DownloadProtocol string `json:"downloadProtocol"`
Protocol string `json:"protocol"` Protocol string `json:"protocol"`
PublishDate string `json:"publishDate"` PublishDate string `json:"publishDate"`
DownloadClientId int `json:"downloadClientId,omitempty"`
} }
type PushResponse struct { type PushResponse struct {
@ -89,7 +91,7 @@ type BadRequestResponse struct {
} }
func (r *BadRequestResponse) String() string { 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 { type SystemStatusResponse struct {

View file

@ -60,6 +60,7 @@ func New(config Config) Client {
type Release struct { type Release struct {
Title string `json:"title"` Title string `json:"title"`
InfoUrl string `json:"infoUrl,omitempty"`
DownloadUrl string `json:"downloadUrl,omitempty"` DownloadUrl string `json:"downloadUrl,omitempty"`
MagnetUrl string `json:"magnetUrl,omitempty"` MagnetUrl string `json:"magnetUrl,omitempty"`
Size int64 `json:"size"` Size int64 `json:"size"`
@ -67,6 +68,7 @@ type Release struct {
DownloadProtocol string `json:"downloadProtocol"` DownloadProtocol string `json:"downloadProtocol"`
Protocol string `json:"protocol"` Protocol string `json:"protocol"`
PublishDate string `json:"publishDate"` PublishDate string `json:"publishDate"`
DownloadClientId int `json:"downloadClientId,omitempty"`
} }
type PushResponse struct { type PushResponse struct {

View file

@ -116,6 +116,8 @@ function FormFieldsArr() {
<PasswordFieldWide name="settings.basic.password" label="Password" /> <PasswordFieldWide name="settings.basic.password" label="Password" />
</> </>
)} )}
<NumberFieldWide name="settings.external_download_client_id" label="Download Client ID" tooltip={<div><p>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.</p></div>} />
</div> </div>
); );
} }

View file

@ -71,6 +71,7 @@ export function FilterActions({ filter, values }: FilterActionsProps) {
webhook_method: "", webhook_method: "",
webhook_data: "", webhook_data: "",
webhook_headers: [], webhook_headers: [],
external_download_client_id: 0,
client_id: 0 client_id: 0
}; };
@ -542,6 +543,11 @@ const TypeForm = ({ action, idx, clients }: TypeFormProps) => {
action={action} action={action}
clients={clients} clients={clients}
/> />
<NumberField
name={`actions.${idx}.external_download_client_id`}
label="Override download client id for arr"
tooltip={<p>Override Download client Id from the one set in Clients. Useful if you have multiple clients inside the arr.</p>}
/>
</div> </div>
); );
case "SABNZBD": case "SABNZBD":

View file

@ -45,6 +45,7 @@ interface DownloadClientSettings {
apikey?: string; apikey?: string;
basic?: DownloadClientBasicAuth; basic?: DownloadClientBasicAuth;
rules?: DownloadClientRules; rules?: DownloadClientRules;
external_download_client_id?: number;
} }
interface DownloadClient { interface DownloadClient {

View file

@ -102,8 +102,9 @@ interface Action {
webhook_method: string; webhook_method: string;
webhook_data: string, webhook_data: string,
webhook_headers: string[]; webhook_headers: string[];
filter_id?: number; external_download_client_id?: number;
client_id?: number; client_id?: number;
filter_id?: number;
} }
type ActionContentLayout = "ORIGINAL" | "SUBFOLDER_CREATE" | "SUBFOLDER_NONE"; type ActionContentLayout = "ORIGINAL" | "SUBFOLDER_CREATE" | "SUBFOLDER_NONE";