Documentation
¶
Overview ¶
Package indexerprobe tests indexers from the catalog that have not been added, so the add-indexer page can recommend ones that work. It also holds the release-matching and error-classification helpers shared with the torznab proxy's search stats.
Index ¶
- Constants
- Variables
- func ErrorKind(err error) string
- func NeedsOverlayNetwork(e indexer.CatalogEntry) bool
- func ReleaseIDOf(res scraper.SearchResult) indexer.ReleaseID
- func SearchMode(t string) string
- type Prober
- func (p *Prober) Eligible(ctx context.Context) (targets []indexer.CatalogEntry, wanted []string, added map[string]bool, ...)
- func (p *Prober) Health(ctx context.Context) (map[string]*SiteHealth, error)
- func (p *Prober) Run(ctx context.Context)
- func (p *Prober) RunCycle(ctx context.Context)
- func (p *Prober) Status() Status
- func (p *Prober) TestNow(ctx context.Context, catalogID string) error
- type Searcher
- type SiteHealth
- type Status
Constants ¶
const ( VerdictWorks = "works" // last test found results VerdictNoResults = "no_results" // answers, but never finds anything VerdictFlaky = "flaky" // last test failed, earlier ones didn't VerdictNeedsFlareSolverr = "needs_flaresolverr" // Cloudflare and no FlareSolverr set up VerdictBlocked = "blocked" // the site has blocked this IP VerdictDown = "down" // failed 3+ tests in a row )
Verdicts, best first.
const ( DefaultInterval = 6 * time.Hour StartDelay = 3 * time.Minute )
The tester runs one test search against each eligible catalog indexer per cycle, gently:
- eligible = public torrent indexers in a category a connected service wants (Prism → Movies, Pilot → TV), not already added, needing no settings without defaults. Private sites are never contacted.
- one search per site per cycle, one site at a time, ~90 s apart with jitter; the same query for every site, so results compare. A site tested in the last 5½ hours is skipped, so restarts resume a round.
- sites failing 3 cycles in a row drop to daily, and to weekly after a week; rate-limited (HTTP 429) and Cloudflare sites to daily.
- a Cloudflare site waits while FlareSolverr is busy with a real search.
Variables ¶
var ErrCooldown = errors.New("tested less than 10 minutes ago")
ErrCooldown is returned by TestNow when the site was tested too recently.
Functions ¶
func NeedsOverlayNetwork ¶
func NeedsOverlayNetwork(e indexer.CatalogEntry) bool
NeedsOverlayNetwork reports whether every address of the indexer is an I2P or Tor hidden service, which Pulse can't reach.
func ReleaseIDOf ¶
func ReleaseIDOf(res scraper.SearchResult) indexer.ReleaseID
ReleaseIDOf identifies a release across indexers: its info hash when known (directly or from a magnet link), plus its normalized title and size so indexers that don't expose hashes can still be matched.
func SearchMode ¶
SearchMode maps a torznab t= function to "movie", "tv" or "search".
Types ¶
type Prober ¶
type Prober struct {
// contains filtered or unexported fields
}
Prober tests catalog indexers in the background.
func New ¶
func New(q db.Querier, search Searcher, catalog func() []indexer.CatalogEntry, logger *slog.Logger) *Prober
New returns a tester. catalog lists the catalog entries (indexer.Catalog).
func (*Prober) Eligible ¶
func (p *Prober) Eligible(ctx context.Context) (targets []indexer.CatalogEntry, wanted []string, added map[string]bool, err error)
Eligible returns the catalog indexers the tester covers, the categories connected services want, and the catalog IDs already added.
func (*Prober) Run ¶
Run tests catalog indexers every interval until ctx ends, starting after StartDelay so a restart doesn't add load while everything boots.
type Searcher ¶
type Searcher interface {
ProbeSearch(ctx context.Context, catalogID, query string) ([]scraper.SearchResult, *scraper.Trace, error)
SolverBusy() bool
HasDefinition(catalogID string) bool
ResolveCatalogID(name, url string) string
}
Searcher is the part of the scraper engine the tester needs.
type SiteHealth ¶
type SiteHealth struct {
CatalogID string `json:"catalog_id"`
Verdict string `json:"verdict"`
// Score ranks sites for "Recommended" (0–100, higher is better).
Score int `json:"score"`
Tests int `json:"tests"`
Failures int `json:"failures"`
SuccessRate float64 `json:"success_rate"`
// Over successful tests:
MedianMs int `json:"median_ms"`
AvgResults float64 `json:"avg_results"`
MedianSeeders int `json:"median_seeders"`
// Comparisons counts tests whose results were compared with other
// sites'; UniqueShare is the share of results nobody else found (0–1).
Comparisons int `json:"comparisons"`
BehindCloudflare float64 `json:"behind_cloudflare"`
SolveRate float64 `json:"solve_rate"`
ConsecutiveFailures int `json:"consecutive_failures"`
LastTestAt string `json:"last_test_at"`
LastOKAt string `json:"last_ok_at,omitempty"`
LastErrorKind string `json:"last_error_kind,omitempty"`
LastError string `json:"last_error,omitempty"`
}
SiteHealth summarizes a catalog indexer's tests over the last 30 days.
type Status ¶
type Status struct {
Running bool `json:"running"`
CycleStartedAt string `json:"cycle_started_at,omitempty"`
LastCycleEndedAt string `json:"last_cycle_ended_at,omitempty"`
NextCycleAt string `json:"next_cycle_at,omitempty"`
Query string `json:"query,omitempty"`
Total int `json:"total"`
Done int `json:"done"`
IntervalHours int `json:"interval_hours"`
WantedCategories []string `json:"wanted_categories"`
}
Status is what the tester is doing, for the add-indexer page.