release / govulncheck (push) Successful in 34s
release / web (push) Successful in 1m13s
release / go (push) Successful in 2m12s
release / integration (push) Successful in 4m6s
release / Build signed APK (releases and dev) (push) Successful in 8m41s
release / android (push) Successful in 9m47s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 59s
release / Verify release artifacts (tag releases only) (push) Skipped
Admin → Integrations gains "Indexers and download clients": two lists of
connections the operator adds, Fabled Librarian's model. Nothing is seeded
or copied from Lidarr.
- Indexers: Prowlarr (its native /api/v1/search, which asks every indexer
at once; Prowlarr has no aggregate Torznab feed) and any Torznab feed.
- Download clients: qBittorrent (WebUI v2, with re-login on an expired
session) and FabledExchange, one entry with a switch per job:
downloads (/api/downloads), search (/api/search) and release details
(/api/torrents/{infohash}). All three start on; its key is optional.
- Each entry: enable, name, address, a write-only key or password, Test.
A download client's Test lists its torrents and checks the downloads
folder is visible and writable from Minstrel; an Exchange's Test
reports each job switched on.
- Download clients carry a path mapping (Minstrel's /downloads vs the
client's own name for it); search sources carry searches per hour.
Migration 0079 adds acquisition_services with its CHECKs. Ported from
Fabled Librarian: internal/indexer (Torznab, 429 Retry-After, magnet
redirects), internal/prowlarr, internal/exchange, internal/downloader,
and internal/acquire's one builder per kind, which Test already uses
so a passing Test vouches for the path a grab will take.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package indexer
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"net/http"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
// RateLimited is a source answering 429. Named so the search pacing can hold
|
|
// that source back for as long as it asked; still an ErrUnreachable to
|
|
// everything else, because this search did not reach it.
|
|
type RateLimited struct {
|
|
// RetryAfter is what the source asked for; zero when it did not say.
|
|
RetryAfter time.Duration
|
|
// Who names the source in the sentence, e.g. "Prowlarr".
|
|
Who string
|
|
}
|
|
|
|
func (e *RateLimited) Error() string {
|
|
return fmt.Sprintf("%v: HTTP 429, %s is rate-limiting this search", ErrUnreachable, e.Who)
|
|
}
|
|
|
|
func (e *RateLimited) Unwrap() error { return ErrUnreachable }
|
|
|
|
// AsRateLimited finds a RateLimited anywhere in err's chain.
|
|
func AsRateLimited(err error) (*RateLimited, bool) {
|
|
var rl *RateLimited
|
|
if errors.As(err, &rl) {
|
|
return rl, true
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// RetryAfter reads a Retry-After header: seconds, or an HTTP date. Zero when
|
|
// absent or unreadable.
|
|
func RetryAfter(h http.Header, now time.Time) time.Duration {
|
|
v := h.Get("Retry-After")
|
|
if v == "" {
|
|
return 0
|
|
}
|
|
if s, err := strconv.Atoi(v); err == nil && s > 0 {
|
|
return time.Duration(s) * time.Second
|
|
}
|
|
if t, err := http.ParseTime(v); err == nil && t.After(now) {
|
|
return t.Sub(now)
|
|
}
|
|
return 0
|
|
}
|