indexerprobe

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

View Source
var ErrCooldown = errors.New("tested less than 10 minutes ago")

ErrCooldown is returned by TestNow when the site was tested too recently.

Functions

func ErrorKind

func ErrorKind(err error) string

ErrorKind classifies a search error for the stats ("" on success).

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

func SearchMode(t string) string

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) Health

func (p *Prober) Health(ctx context.Context) (map[string]*SiteHealth, error)

Health summarizes every tested catalog indexer, keyed by catalog ID.

func (*Prober) Run

func (p *Prober) Run(ctx context.Context)

Run tests catalog indexers every interval until ctx ends, starting after StartDelay so a restart doesn't add load while everything boots.

func (*Prober) RunCycle

func (p *Prober) RunCycle(ctx context.Context)

RunCycle tests every eligible site that is due, once.

func (*Prober) Status

func (p *Prober) Status() Status

Status returns a snapshot of what the tester is doing.

func (*Prober) TestNow

func (p *Prober) TestNow(ctx context.Context, catalogID string) error

TestNow tests one catalog indexer immediately (the "Test now" button). Limited to once per 10 minutes per site.

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"`
	UniqueShare      float64 `json:"unique_share"`
	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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL