mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(clients): add whisparr (#218)
* feat(clients): add whisparr * feat: add client connection test
This commit is contained in:
parent
2f358473f3
commit
9d0ab6ea52
11 changed files with 338 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
|||
package download_client
|
||||
|
||||
import (
|
||||
"github.com/autobrr/autobrr/pkg/whisparr"
|
||||
"github.com/pkg/errors"
|
||||
"time"
|
||||
|
||||
"github.com/autobrr/autobrr/internal/domain"
|
||||
|
@ -29,9 +31,12 @@ func (s *service) testConnection(client domain.DownloadClient) error {
|
|||
|
||||
case domain.DownloadClientTypeLidarr:
|
||||
return s.testLidarrConnection(client)
|
||||
}
|
||||
|
||||
return nil
|
||||
case domain.DownloadClientTypeWhisparr:
|
||||
return s.testWhisparrConnection(client)
|
||||
default:
|
||||
return errors.New("unsupported client")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *service) testQbittorrentConnection(client domain.DownloadClient) error {
|
||||
|
@ -159,3 +164,23 @@ func (s *service) testLidarrConnection(client domain.DownloadClient) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) testWhisparrConnection(client domain.DownloadClient) error {
|
||||
r := whisparr.New(whisparr.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("whisparr: connection test failed: %v", client.Host)
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debug().Msgf("test client connection for whisparr: success")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue