indexer

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 20 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 indexer manages indexer configurations and orchestrates release searches.

Index

Constants

This section is empty.

Variables

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

func (s *Service) Create(ctx context.Context, req CreateRequest) (Config, error)

Create persists a new indexer configuration.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

Delete removes an indexer config. Returns ErrNotFound if absent.

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (Config, error)

Get returns an indexer config by ID. Returns ErrNotFound if absent.

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

func (s *Service) GetSeedCriteria(ctx context.Context, indexerID string) (SeedCriteria, error)

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

func (s *Service) GrabHistory(ctx context.Context, movieID string) ([]dbgen.GrabHistory, error)

GrabHistory returns the grab history for a movie, newest first.

func (*Service) List

func (s *Service) List(ctx context.Context) ([]Config, error)

List returns all indexer configs, ordered by priority then name.

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

func (s *Service) Test(ctx context.Context, id string) error

Test instantiates the indexer plugin and verifies connectivity.

func (*Service) Update

func (s *Service) Update(ctx context.Context, id string, req UpdateRequest) (Config, error)

Update replaces the mutable fields of an indexer config. Returns ErrNotFound if the indexer does not exist.

type UpdateRequest

type UpdateRequest = CreateRequest

UpdateRequest carries the fields needed to update an indexer config.

Jump to

Keyboard shortcuts

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