Feature: Sonarr (#14)

* feat: add sonarr download client

* feat(web): add sonarr download client and actions

* feat: add sonarr to filter actions
This commit is contained in:
Ludvig Lundgren 2021-08-22 00:55:00 +02:00 committed by GitHub
parent 455284a94b
commit fce6c7149a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 594 additions and 5 deletions

View file

@ -6,6 +6,7 @@ import (
"github.com/autobrr/autobrr/internal/domain"
"github.com/autobrr/autobrr/pkg/qbittorrent"
"github.com/autobrr/autobrr/pkg/radarr"
"github.com/autobrr/autobrr/pkg/sonarr"
delugeClient "github.com/gdm85/go-libdeluge"
"github.com/rs/zerolog/log"
@ -21,6 +22,9 @@ func (s *service) testConnection(client domain.DownloadClient) error {
case domain.DownloadClientTypeRadarr:
return s.testRadarrConnection(client)
case domain.DownloadClientTypeSonarr:
return s.testSonarrConnection(client)
}
return nil
@ -106,3 +110,21 @@ func (s *service) testRadarrConnection(client domain.DownloadClient) error {
return nil
}
func (s *service) testSonarrConnection(client domain.DownloadClient) error {
r := sonarr.New(sonarr.Config{
Hostname: client.Host,
APIKey: client.Settings.APIKey,
BasicAuth: client.Settings.Basic.Auth,
Username: client.Settings.Basic.Username,
Password: client.Settings.Basic.Password,
})
_, err := r.Test()
if err != nil {
log.Error().Err(err).Msgf("sonarr: connection test failed: %v", client.Host)
return err
}
return nil
}