mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
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:
parent
8bef297841
commit
8925266104
9 changed files with 481 additions and 3 deletions
|
@ -339,6 +339,7 @@ type TorrentBasic struct {
|
|||
TorrentId string `json:"TorrentId,omitempty"`
|
||||
InfoHash string `json:"InfoHash"`
|
||||
Size string `json:"Size"`
|
||||
Uploader string `json:"Uploader"`
|
||||
}
|
||||
|
||||
func (t TorrentBasic) ReleaseSizeBytes() uint64 {
|
||||
|
|
|
@ -439,9 +439,10 @@ func (s *service) AdditionalSizeCheck(ctx context.Context, f domain.Filter, rele
|
|||
s.log.Debug().Msgf("filter.Service.AdditionalSizeCheck: (%s) additional size check required", f.Name)
|
||||
|
||||
switch release.Indexer {
|
||||
case "ptp", "btn", "ggn", "redacted", "mock":
|
||||
case "ptp", "btn", "ggn", "redacted", "ops", "mock":
|
||||
if release.Size == 0 {
|
||||
s.log.Trace().Msgf("filter.Service.AdditionalSizeCheck: (%s) preparing to check via api", f.Name)
|
||||
|
||||
torrentInfo, err := s.apiService.GetTorrentByID(ctx, release.Indexer, release.TorrentID)
|
||||
if err != nil || torrentInfo == nil {
|
||||
s.log.Error().Stack().Err(err).Msgf("filter.Service.AdditionalSizeCheck: (%s) could not get torrent info from api: '%s' from: %s", f.Name, release.TorrentID, release.Indexer)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ urls:
|
|||
privacy: private
|
||||
protocol: torrent
|
||||
supports:
|
||||
- api
|
||||
- irc
|
||||
- rss
|
||||
source: gazelle
|
||||
|
@ -19,6 +20,24 @@ settings:
|
|||
label: Torrent pass
|
||||
help: Right click DL on a torrent and get the torrent_pass.
|
||||
|
||||
- name: api_key
|
||||
type: secret
|
||||
required: true
|
||||
label: API Key
|
||||
help: Settings -> Access Settings -> API Keys - Create a new api token.
|
||||
|
||||
api:
|
||||
url: https://orpheus.network/ajax.php
|
||||
type: json
|
||||
limits:
|
||||
max: 5
|
||||
per: 10 seconds
|
||||
settings:
|
||||
- name: api_key
|
||||
type: secret
|
||||
label: API Key
|
||||
help: Settings -> Access Settings -> API Keys - Create a new api token.
|
||||
|
||||
irc:
|
||||
network: Orpheus
|
||||
server: irc.orpheus.network
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue