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
}
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)

View file

@ -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)

View file

@ -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)

View file

@ -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{

View file

@ -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)

View file

@ -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)