feat(indexers): add API support for Orpheus to fetch size (#944)

* feat(indexers): add API support for Orpheus

* feat(filters): add ops to AdditionalSizeCheck
This commit is contained in:
ze0s 2023-05-21 16:55:10 +02:00 committed by GitHub
parent 8bef297841
commit 8925266104
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 481 additions and 3 deletions

View file

@ -6,16 +6,17 @@ package indexer
import (
"context"
"github.com/rs/zerolog"
"github.com/autobrr/autobrr/internal/domain"
"github.com/autobrr/autobrr/internal/logger"
"github.com/autobrr/autobrr/internal/mock"
"github.com/autobrr/autobrr/pkg/btn"
"github.com/autobrr/autobrr/pkg/errors"
"github.com/autobrr/autobrr/pkg/ggn"
"github.com/autobrr/autobrr/pkg/ops"
"github.com/autobrr/autobrr/pkg/ptp"
"github.com/autobrr/autobrr/pkg/red"
"github.com/rs/zerolog"
)
type APIService interface {
@ -115,6 +116,13 @@ func (s *apiService) AddClient(indexer string, settings map[string]string) error
}
s.apiClients[indexer] = red.NewClient(key)
case "ops":
key, ok := settings["api_key"]
if !ok || key == "" {
return errors.New("api.Service.AddClient: could not initialize orpheus client: missing var 'api_key'")
}
s.apiClients[indexer] = ops.NewClient(key)
case "mock":
s.apiClients[indexer] = mock.NewMockClient("", "mock")
@ -166,6 +174,12 @@ func (s *apiService) getClientForTest(req domain.IndexerTestApiRequest) (apiClie
}
return red.NewClient(req.ApiKey), nil
case "ops":
if req.ApiKey == "" {
return nil, errors.New("api.Service.AddClient: could not initialize orpheus client: missing var 'api_key'")
}
return ops.NewClient(req.ApiKey), nil
case "mock":
return mock.NewMockClient("", "mock"), nil