feat(download-client): add support for Porla (#553)

* Add support for the 'Test' button to work

* Make Porla show up in filter actions select

* Add an empty Porla action

* Make Porla action find download client

* Make implementation actually add torrent to Porla

* Fix qBittorrent import

* Finish up Porla action

* Check length on commitish before slicing

* Move Porla to the other DL clients

* Add Porla to type name map

* Move Porla to beneath the other download clients
This commit is contained in:
Viktor Elofsson 2023-01-29 18:17:01 +01:00 committed by GitHub
parent b95c1e6913
commit 870e109f6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 271 additions and 2 deletions

View file

@ -7,6 +7,7 @@ import (
"github.com/autobrr/autobrr/internal/domain"
"github.com/autobrr/autobrr/pkg/errors"
"github.com/autobrr/autobrr/pkg/lidarr"
"github.com/autobrr/autobrr/pkg/porla"
"github.com/autobrr/autobrr/pkg/radarr"
"github.com/autobrr/autobrr/pkg/readarr"
"github.com/autobrr/autobrr/pkg/sonarr"
@ -32,6 +33,9 @@ func (s *service) testConnection(ctx context.Context, client domain.DownloadClie
case domain.DownloadClientTypeTransmission:
return s.testTransmissionConnection(ctx, client)
case domain.DownloadClientTypePorla:
return s.testPorlaConnection(client)
case domain.DownloadClientTypeRadarr:
return s.testRadarrConnection(ctx, client)
@ -258,3 +262,26 @@ func (s *service) testReadarrConnection(ctx context.Context, client domain.Downl
return nil
}
func (s *service) testPorlaConnection(client domain.DownloadClient) error {
p := porla.NewClient(porla.Settings{
Hostname: client.Host,
AuthToken: client.Settings.APIKey,
})
version, err := p.Version()
if err != nil {
return errors.Wrap(err, "porla: failed to get version: %v", client.Host)
}
commitish := version.Commitish
if len(commitish) > 8 {
commitish = commitish[:8]
}
s.log.Debug().Msgf("test client connection for porla: found version %s (commit %s)", version.Version, commitish)
return nil
}