indexer

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CatalogLanguages

func CatalogLanguages() []string

CatalogLanguages returns the distinct languages present in the catalog.

func SetCatalogSource

func SetCatalogSource(fn func() []CatalogEntry)

SetCatalogSource replaces the catalog provider function. Call this once at startup after creating a ProwlarrCatalog.

Types

type AssignmentInput

type AssignmentInput struct {
	IndexerID string `json:"indexer_id"`
	ServiceID string `json:"service_id"`
	Overrides string `json:"overrides"`
}

AssignmentInput specifies how to assign an indexer to a service.

type AutoAssigner

type AutoAssigner struct {
	// contains filtered or unexported fields
}

AutoAssigner handles automatic indexer-to-service assignment based on category↔capability matching.

func NewAutoAssigner

func NewAutoAssigner(q db.Querier, pusher *Pusher, logger *slog.Logger) *AutoAssigner

NewAutoAssigner creates a new AutoAssigner.

func (*AutoAssigner) AssignExistingIndexersToService

func (a *AutoAssigner) AssignExistingIndexersToService(ctx context.Context, serviceID string)

AssignExistingIndexersToService finds all unassigned indexers whose categories match the service's content:* capabilities and creates assignments. Called when a new service registers.

func (*AutoAssigner) AssignIndexerToMatchingServices

func (a *AutoAssigner) AssignIndexerToMatchingServices(ctx context.Context, indexerID string, categories []string)

AssignIndexerToMatchingServices finds all services whose content:* capabilities match the indexer's categories and creates assignments. Called when an indexer is created.

type CatalogEntry

type CatalogEntry struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Language    string   `json:"language"`
	Protocol    string   `json:"protocol"`   // torrent, usenet
	Privacy     string   `json:"privacy"`    // public, semi-private, private
	Categories  []string `json:"categories"` // Movies, TV, Audio, Books, XXX, Other
	URLs        []string `json:"urls"`
	Settings    []Field  `json:"settings"` // config fields required to add this indexer
}

CatalogEntry describes an available indexer that users can browse and add. This is the "template" — not yet configured or saved.

func Catalog

func Catalog() []CatalogEntry

Catalog returns the current catalog entries (from Prowlarr or static fallback).

func FilterCatalog

func FilterCatalog(filter CatalogFilter) []CatalogEntry

FilterCatalog returns catalog entries matching the given filter.

type CatalogFilter

type CatalogFilter struct {
	Query    string `json:"query,omitempty"`
	Protocol string `json:"protocol,omitempty"`
	Privacy  string `json:"privacy,omitempty"`
	Category string `json:"category,omitempty"`
	Language string `json:"language,omitempty"`
}

CatalogFilter holds the query parameters for browsing the catalog.

type Field

type Field struct {
	Name        string        `json:"name"`
	Type        string        `json:"type"` // text, password, checkbox, select, info
	Label       string        `json:"label"`
	HelpText    string        `json:"help_text,omitempty"`
	Required    bool          `json:"required"`
	Default     string        `json:"default,omitempty"`
	Placeholder string        `json:"placeholder,omitempty"`
	Options     []FieldOption `json:"options,omitempty"` // for select type
}

Field describes a single user-configurable setting for an indexer.

type FieldOption

type FieldOption struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

FieldOption is a name/value pair for select fields.

type IndexerInfo

type IndexerInfo struct {
	db.Indexer
	AssignedServices []string `json:"assigned_services,omitempty"`
}

IndexerInfo is the enriched view with assignments.

type Input

type Input struct {
	Name     string `json:"name"`
	Kind     string `json:"kind"`
	Enabled  bool   `json:"enabled"`
	Priority int    `json:"priority"`
	URL      string `json:"url"`
	APIKey   string `json:"api_key"`
	Settings string `json:"settings"`
}

Input is the data required to create or update an indexer.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles centralized indexer management.

func NewManager

func NewManager(q db.Querier, bus *events.Bus, logger *slog.Logger) *Manager

NewManager creates a new indexer manager.

func (*Manager) Assign

func (m *Manager) Assign(ctx context.Context, input AssignmentInput) (*db.IndexerAssignment, error)

Assign links an indexer to a service.

func (*Manager) AutoAssigner

func (m *Manager) AutoAssigner() *AutoAssigner

AutoAssigner returns the auto-assigner for use by other packages (e.g., service registry for retroactive assignment on registration).

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, input Input) (*db.Indexer, error)

Create adds a new indexer.

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, id string) error

Delete removes an indexer and its assignments, and notifies all affected services so they can remove the indexer locally.

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, id string) (*db.Indexer, error)

Get returns a single indexer.

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]db.Indexer, error)

List returns all indexers.

func (*Manager) ListAssignments

func (m *Manager) ListAssignments(ctx context.Context, indexerID string) ([]db.IndexerAssignment, error)

ListAssignments returns all assignments for an indexer.

func (*Manager) ListEnabled

func (m *Manager) ListEnabled(ctx context.Context) ([]db.Indexer, error)

ListEnabled returns only enabled indexers.

func (*Manager) ListForService

func (m *Manager) ListForService(ctx context.Context, serviceID string) ([]db.Indexer, error)

ListForService returns indexers assigned to a specific service.

func (*Manager) Unassign

func (m *Manager) Unassign(ctx context.Context, indexerID, serviceID string) error

Unassign removes an indexer-service link.

func (*Manager) Update

func (m *Manager) Update(ctx context.Context, id string, input Input) (*db.Indexer, error)

Update modifies an existing indexer.

type ProwlarrCatalog

type ProwlarrCatalog struct {
	// contains filtered or unexported fields
}

ProwlarrCatalog manages a catalog sourced from Prowlarr's GitHub repo.

func NewProwlarrCatalog

func NewProwlarrCatalog(logger *slog.Logger) *ProwlarrCatalog

NewProwlarrCatalog creates a catalog that pulls from Prowlarr's definitions. It initializes with the static fallback and fetches live data asynchronously.

func (*ProwlarrCatalog) AllRawYAML

func (pc *ProwlarrCatalog) AllRawYAML() map[string][]byte

AllRawYAML returns all raw YAML bytes, keyed by catalog ID.

func (*ProwlarrCatalog) Entries

func (pc *ProwlarrCatalog) Entries() []CatalogEntry

Entries returns the current catalog entries.

func (*ProwlarrCatalog) LastFetched

func (pc *ProwlarrCatalog) LastFetched() time.Time

LastFetched returns when the catalog was last refreshed from Prowlarr.

func (*ProwlarrCatalog) RawYAML

func (pc *ProwlarrCatalog) RawYAML(catalogID string) ([]byte, bool)

RawYAML returns the raw YAML bytes for a catalog entry, used by the scraper engine.

func (*ProwlarrCatalog) Refresh

func (pc *ProwlarrCatalog) Refresh(ctx context.Context) error

Refresh fetches the latest definitions from Prowlarr's GitHub repo. On failure it keeps the existing catalog (either previous fetch or static fallback).

func (*ProwlarrCatalog) StartRefreshLoop

func (pc *ProwlarrCatalog) StartRefreshLoop(ctx context.Context, interval time.Duration)

StartRefreshLoop refreshes the catalog immediately, then periodically.

type Pusher

type Pusher struct {
	// contains filtered or unexported fields
}

Pusher notifies services when their indexer assignments change. It POSTs to each affected service's sync webhook endpoint.

func NewPusher

func NewPusher(q db.Querier, logger *slog.Logger) *Pusher

NewPusher creates a new Pusher.

func (*Pusher) NotifyAllAssigned

func (p *Pusher) NotifyAllAssigned(ctx context.Context, indexerID string)

NotifyAllAssigned notifies all services that have the given indexer assigned.

func (*Pusher) NotifyService

func (p *Pusher) NotifyService(ctx context.Context, serviceID string)

NotifyService sends a sync trigger to a service's Pulse webhook. The endpoint is: POST {service.api_url}/api/v1/hooks/pulse/sync

func (*Pusher) NotifyServiceAsync

func (p *Pusher) NotifyServiceAsync(serviceID string)

NotifyServiceAsync is a fire-and-forget version of NotifyService.

type TestResult

type TestResult struct {
	Success  bool   `json:"success"`
	Message  string `json:"message"`
	Duration string `json:"duration"`
}

TestResult holds the outcome of probing an indexer.

func TestIndexer

func TestIndexer(ctx context.Context, kind, url, apiKey string) TestResult

TestIndexer probes an indexer URL to validate connectivity and credentials. For Torznab/Newznab it performs a caps query; for generic URLs it checks HTTP status.

Jump to

Keyboard shortcuts

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