feat(clients): add Readarr support (#490)

* Add initial Readarr support

* Readarr working with MaM

* feat(clients): readarr add tests
This commit is contained in:
voltron4lyfe 2022-10-14 10:56:42 -07:00 committed by GitHub
parent b7d2161fdb
commit 71d0424b61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 626 additions and 6 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/autobrr/autobrr/pkg/lidarr"
"github.com/autobrr/autobrr/pkg/qbittorrent"
"github.com/autobrr/autobrr/pkg/radarr"
"github.com/autobrr/autobrr/pkg/readarr"
"github.com/autobrr/autobrr/pkg/sonarr"
"github.com/autobrr/autobrr/pkg/whisparr"
@ -42,6 +43,9 @@ func (s *service) testConnection(client domain.DownloadClient) error {
case domain.DownloadClientTypeWhisparr:
return s.testWhisparrConnection(client)
case domain.DownloadClientTypeReadarr:
return s.testReadarrConnection(client)
default:
return errors.New("unsupported client")
}
@ -242,3 +246,23 @@ func (s *service) testWhisparrConnection(client domain.DownloadClient) error {
return nil
}
func (s *service) testReadarrConnection(client domain.DownloadClient) error {
r := readarr.New(readarr.Config{
Hostname: client.Host,
APIKey: client.Settings.APIKey,
BasicAuth: client.Settings.Basic.Auth,
Username: client.Settings.Basic.Username,
Password: client.Settings.Basic.Password,
Log: s.subLogger,
})
_, err := r.Test()
if err != nil {
return errors.Wrap(err, "readarr: connection test failed: %v", client.Host)
}
s.log.Debug().Msgf("test client connection for readarr: success")
return nil
}