Documentation
¶
Overview ¶
Package indexer manages indexer configurations and orchestrates release searches.
Index ¶
- Variables
- type Config
- type CreateRequest
- type Outcome
- type SearchResult
- type SeedCriteria
- type Service
- func (s *Service) ActiveGrabForMovie(ctx context.Context, movieID string) (*dbgen.GrabHistory, error)
- func (s *Service) Create(ctx context.Context, req CreateRequest) (Config, error)
- func (s *Service) Delete(ctx context.Context, id string) error
- func (s *Service) Get(ctx context.Context, id string) (Config, error)
- func (s *Service) GetRecent(ctx context.Context) ([]SearchResult, error)
- func (s *Service) GetSeedCriteria(ctx context.Context, indexerID string) (SeedCriteria, error)
- func (s *Service) Grab(ctx context.Context, movieID, indexerID string, r plugin.Release, ...) (dbgen.GrabHistory, error)
- func (s *Service) GrabHistory(ctx context.Context, movieID string) ([]dbgen.GrabHistory, error)
- func (s *Service) List(ctx context.Context) ([]Config, error)
- func (s *Service) ListHistory(ctx context.Context, limit int, status, protocol string) ([]dbgen.GrabHistory, error)
- func (s *Service) LoadHealth(ctx context.Context) error
- func (s *Service) Search(ctx context.Context, query plugin.SearchQuery, allowedIDs []string) ([]SearchResult, error)
- func (s *Service) SearchInteractive(ctx context.Context, query plugin.SearchQuery, onUpdate func(Snapshot)) (Snapshot, error)
- func (s *Service) Test(ctx context.Context, id string) error
- func (s *Service) Update(ctx context.Context, id string, req UpdateRequest) (Config, error)
- type Snapshot
- type UpdateRequest
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("indexer not found")
ErrNotFound is returned when an indexer config does not exist.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ID string
Name string
Kind string // "torznab", "newznab"
Enabled bool
Priority int
Settings json.RawMessage
MinSeeders int // releases below this threshold get tagged with a filter reason
CreatedAt time.Time
UpdatedAt time.Time
}
Config is the domain representation of a stored indexer configuration.
type CreateRequest ¶
type CreateRequest struct {
Name string
Kind string
Enabled bool
Priority int
Settings json.RawMessage
MinSeeders int // 0 means "use the sensible default (5)"
}
CreateRequest carries the fields needed to create an indexer config.
type Outcome ¶ added in v0.14.1
type Outcome struct {
IndexerID string
IndexerName string
Results int
Error string // empty on success
// Pending: the indexer hit our deadline but its scrape continues
// server-side and will be cached; not a failure.
Pending bool
// Searching: no answer yet. Only in the snapshots of a running search.
Searching bool
}
Outcome is how one indexer did in a search.
type SearchResult ¶
type SearchResult struct {
plugin.Release
// IndexerID is the DB UUID of the indexer that returned this release.
IndexerID string
QualityScore int
ScoreBreakdown plugin.ScoreBreakdown
// OtherSources lists the OTHER indexer names that reported the same
// torrent (matched by info_hash) and whose seed/peer counts were folded
// into the median displayed on this row. Empty when the release came
// from a single indexer or the info_hash couldn't be determined. See
// dedupeByInfoHash for the merge logic.
OtherSources []string
// FilterReasons accumulates one human-readable string per safety
// filter that flagged this release ("below minimum seeders (3 < 5)",
// "blocklisted", etc.). The manual-search UI renders flagged rows
// grayed-with-an-override-button so the user keeps agency; auto-grab
// skips any row with non-empty FilterReasons. Hiding rows outright
// creates content-loss traps, which is why we tag instead of drop.
FilterReasons []string
}
SearchResult pairs a plugin release with its parsed quality score.
type SeedCriteria ¶
type SeedCriteria struct {
SeedRatio float64 // 0 = use client default
SeedTimeMinutes int // 0 = no limit
}
SeedCriteria holds the per-indexer seeding requirements applied to torrents after import. Zero values mean "use download client default".
func ExtractSeedCriteria ¶
func ExtractSeedCriteria(settings json.RawMessage) SeedCriteria
ExtractSeedCriteria parses seed_ratio and seed_time_minutes from an indexer's settings JSON. Returns zero values if the fields are absent.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages indexer configuration and search orchestration.
func NewService ¶
func NewService(q dbgen.Querier, reg *registry.Registry, bus *events.Bus, rl *ratelimit.Registry) *Service
NewService creates a new Service.
func (*Service) ActiveGrabForMovie ¶
func (s *Service) ActiveGrabForMovie(ctx context.Context, movieID string) (*dbgen.GrabHistory, error)
ActiveGrabForMovie returns the active (non-terminal) grab for a movie, if any. The grab_history table has a partial unique index that prevents more than one such row per movie — this method is the read-side counterpart that callers can use to detect "already downloading" state before attempting another grab. Returns (nil, nil) when no active grab exists.
Active = download_status NOT IN ('completed', 'failed', 'removed') — matches the WHERE clause on idx_grab_history_active_movie.
func (*Service) GetRecent ¶
func (s *Service) GetRecent(ctx context.Context) ([]SearchResult, error)
GetRecent fetches the most recent releases from all enabled indexers and returns them merged and sorted by quality score descending. Errors from individual indexers are collected and returned alongside any results gathered.
func (*Service) GetSeedCriteria ¶
GetSeedCriteria loads the seed criteria from an indexer's settings JSON.
func (*Service) Grab ¶
func (s *Service) Grab(ctx context.Context, movieID, indexerID string, r plugin.Release, downloadClientID, clientItemID, scoreBreakdownJSON string) (dbgen.GrabHistory, error)
Grab records a grab to history and links it to the download client that accepted the release. Pass empty strings for downloadClientID / clientItemID when no client is involved. scoreBreakdownJSON is a pre-serialized plugin.ScoreBreakdown; pass "" when not available.
func (*Service) GrabHistory ¶
GrabHistory returns the grab history for a movie, newest first.
func (*Service) ListHistory ¶
func (s *Service) ListHistory(ctx context.Context, limit int, status, protocol string) ([]dbgen.GrabHistory, error)
ListHistory returns the most recent grab history entries across all movies, optionally filtered by download status and/or protocol.
func (*Service) LoadHealth ¶ added in v0.14.1
LoadHealth restores indexer health saved by an earlier run. Nothing saved, or something unreadable, starts fresh.
func (*Service) Search ¶
func (s *Service) Search(ctx context.Context, query plugin.SearchQuery, allowedIDs []string) ([]SearchResult, error)
Search queries enabled indexers for the given search query and returns scored, sorted results. If allowedIDs is non-nil, only indexers whose ID appears in the slice are searched (tag-based filtering). Pass nil to search all enabled indexers.
func (*Service) SearchInteractive ¶ added in v0.14.1
func (s *Service) SearchInteractive(ctx context.Context, query plugin.SearchQuery, onUpdate func(Snapshot)) (Snapshot, error)
SearchInteractive runs a search for a person watching the results: onUpdate is called each time an indexer answers, with everything found so far, and an indexer that keeps missing is waited on for struggleTimeout rather than the full timeout. onUpdate calls are serialized and arrive in order; keep them quick.
type Snapshot ¶ added in v0.14.1
type Snapshot struct {
Results []SearchResult
Outcomes []Outcome
Done bool
}
Snapshot is a search's results so far, ranked and tagged exactly as the finished search will be, with where each indexer stands.
type UpdateRequest ¶
type UpdateRequest = CreateRequest
UpdateRequest carries the fields needed to update an indexer config.