models

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: GPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTypeConnection     = "connection"
	ErrorTypeAuthentication = "authentication"
	ErrorTypeBan            = "ban"
	ErrorTypeAPI            = "api"
)

Error types for categorization

View Source
const (
	LicenseStatusActive  = "active"
	LicenseStatusInvalid = "invalid"
)

LicenseStatus constants

Variables

View Source
var (
	ErrTorznabIndexerNotFound   = errors.New("torznab indexer not found")
	ErrTorznabIndexerIDRequired = errors.New("indexer_id is required for prowlarr backends")
)
View Source
var DefaultSectionOrder = []string{"server-stats", "tracker-breakdown", "global-stats", "instances"}

Default section order

View Source
var DefaultSectionVisibility = map[string]bool{
	"server-stats":      true,
	"tracker-breakdown": true,
	"global-stats":      true,
	"instances":         true,
}

Default section visibility (all visible)

View Source
var ErrAPIKeyNotFound = errors.New("api key not found")
View Source
var ErrClientAPIKeyNotFound = errors.New("client api key not found")
View Source
var ErrExternalProgramNotFound = errors.New("external program not found")
View Source
var ErrInstanceNotFound = errors.New("instance not found")
View Source
var ErrInvalidAPIKey = errors.New("invalid api key")
View Source
var (
	ErrLicenseNotFound = errors.New("license not found")
)
View Source
var ErrUserAlreadyExists = errors.New("user already exists")
View Source
var ErrUserNotFound = errors.New("user not found")

Functions

func BoolToSQLite added in v1.10.0

func BoolToSQLite(v bool) int

BoolToSQLite converts a bool to SQLite integer representation (0 or 1).

func DecodeStringSliceJSON added in v1.10.0

func DecodeStringSliceJSON(raw sql.NullString) ([]string, error)

DecodeStringSliceJSON unmarshals a JSON string to a sanitized string slice. Returns an empty slice for NULL or empty database values.

func EncodeStringSliceJSON added in v1.10.0

func EncodeStringSliceJSON(values []string) (string, error)

EncodeStringSliceJSON marshals a string slice to JSON. Returns "[]" for empty/nil slices.

func GenerateAPIKey

func GenerateAPIKey() (string, error)

GenerateAPIKey generates a new API key

func HashAPIKey

func HashAPIKey(key string) string

HashAPIKey creates a SHA256 hash of the API key

func SanitizeStringSlice added in v1.10.0

func SanitizeStringSlice(values []string) []string

SanitizeStringSlice trims whitespace, removes empty strings, and deduplicates case-insensitively. Original casing is preserved for the first occurrence of each unique value.

Types

type APIKey

type APIKey struct {
	ID         int        `json:"id"`
	KeyHash    string     `json:"-"`
	Name       string     `json:"name"`
	CreatedAt  time.Time  `json:"createdAt"`
	LastUsedAt *time.Time `json:"lastUsedAt,omitempty"`
}

type APIKeyStore

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

func NewAPIKeyStore

func NewAPIKeyStore(db dbinterface.Querier) *APIKeyStore

func (*APIKeyStore) Create

func (s *APIKeyStore) Create(ctx context.Context, name string) (string, *APIKey, error)

func (*APIKeyStore) Delete

func (s *APIKeyStore) Delete(ctx context.Context, id int) error

func (*APIKeyStore) GetByHash

func (s *APIKeyStore) GetByHash(ctx context.Context, keyHash string) (*APIKey, error)

func (*APIKeyStore) List

func (s *APIKeyStore) List(ctx context.Context) ([]*APIKey, error)

func (*APIKeyStore) UpdateLastUsed

func (s *APIKeyStore) UpdateLastUsed(ctx context.Context, id int) error

func (*APIKeyStore) ValidateAPIKey

func (s *APIKeyStore) ValidateAPIKey(ctx context.Context, rawKey string) (*APIKey, error)

ValidateAPIKey validates a raw API key and returns the associated APIKey if valid

type BackupItem added in v1.5.0

type BackupItem struct {
	ID              int64     `json:"id"`
	RunID           int64     `json:"runId"`
	TorrentHash     string    `json:"torrentHash"`
	Name            string    `json:"name"`
	Category        *string   `json:"category,omitempty"`
	SizeBytes       int64     `json:"sizeBytes"`
	ArchiveRelPath  *string   `json:"archiveRelPath,omitempty"`
	InfoHashV1      *string   `json:"infohashV1,omitempty"`
	InfoHashV2      *string   `json:"infohashV2,omitempty"`
	Tags            *string   `json:"tags,omitempty"`
	TorrentBlobPath *string   `json:"torrentBlobPath,omitempty"`
	CreatedAt       time.Time `json:"createdAt"`
}

type BackupRun added in v1.5.0

type BackupRun struct {
	ID             int64                       `json:"id"`
	InstanceID     int                         `json:"instanceId"`
	Kind           BackupRunKind               `json:"kind"`
	Status         BackupRunStatus             `json:"status"`
	RequestedBy    string                      `json:"requestedBy"`
	RequestedAt    time.Time                   `json:"requestedAt"`
	StartedAt      *time.Time                  `json:"startedAt,omitempty"`
	CompletedAt    *time.Time                  `json:"completedAt,omitempty"`
	ArchivePath    *string                     `json:"archivePath,omitempty"`
	ManifestPath   *string                     `json:"manifestPath,omitempty"`
	TotalBytes     int64                       `json:"totalBytes"`
	TorrentCount   int                         `json:"torrentCount"`
	CategoryCounts map[string]int              `json:"categoryCounts,omitempty"`
	ErrorMessage   *string                     `json:"errorMessage,omitempty"`
	Categories     map[string]CategorySnapshot `json:"categories,omitempty"`
	Tags           []string                    `json:"tags,omitempty"`
	// contains filtered or unexported fields
}

type BackupRunKind added in v1.5.0

type BackupRunKind string
const (
	BackupRunKindManual  BackupRunKind = "manual"
	BackupRunKindHourly  BackupRunKind = "hourly"
	BackupRunKindDaily   BackupRunKind = "daily"
	BackupRunKindWeekly  BackupRunKind = "weekly"
	BackupRunKindMonthly BackupRunKind = "monthly"
)

type BackupRunStatus added in v1.5.0

type BackupRunStatus string
const (
	BackupRunStatusPending  BackupRunStatus = "pending"
	BackupRunStatusRunning  BackupRunStatus = "running"
	BackupRunStatusSuccess  BackupRunStatus = "success"
	BackupRunStatusFailed   BackupRunStatus = "failed"
	BackupRunStatusCanceled BackupRunStatus = "canceled"
)

type BackupSettings added in v1.5.0

type BackupSettings struct {
	InstanceID        int       `json:"instanceId"`
	Enabled           bool      `json:"enabled"`
	HourlyEnabled     bool      `json:"hourlyEnabled"`
	DailyEnabled      bool      `json:"dailyEnabled"`
	WeeklyEnabled     bool      `json:"weeklyEnabled"`
	MonthlyEnabled    bool      `json:"monthlyEnabled"`
	KeepHourly        int       `json:"keepHourly"`
	KeepDaily         int       `json:"keepDaily"`
	KeepWeekly        int       `json:"keepWeekly"`
	KeepMonthly       int       `json:"keepMonthly"`
	IncludeCategories bool      `json:"includeCategories"`
	IncludeTags       bool      `json:"includeTags"`
	CustomPath        *string   `json:"customPath,omitempty"`
	CreatedAt         time.Time `json:"createdAt"`
	UpdatedAt         time.Time `json:"updatedAt"`
}

func DefaultBackupSettings added in v1.5.0

func DefaultBackupSettings(instanceID int) *BackupSettings

type BackupStore added in v1.5.0

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

func NewBackupStore added in v1.5.0

func NewBackupStore(db dbinterface.Querier) *BackupStore

func (*BackupStore) CleanupRun added in v1.5.0

func (s *BackupStore) CleanupRun(ctx context.Context, runID int64) error

func (*BackupStore) CleanupRuns added in v1.8.0

func (s *BackupStore) CleanupRuns(ctx context.Context, runIDs []int64) error

func (*BackupStore) CountBlobReferences added in v1.5.0

func (s *BackupStore) CountBlobReferences(ctx context.Context, relPath string) (int, error)

func (*BackupStore) CountBlobReferencesBatch added in v1.8.0

func (s *BackupStore) CountBlobReferencesBatch(ctx context.Context, relPaths []string) (map[string]int, error)

func (*BackupStore) CountRunsByKind added in v1.5.0

func (s *BackupStore) CountRunsByKind(ctx context.Context, instanceID int, kind BackupRunKind) (int, error)

func (*BackupStore) CreateRun added in v1.5.0

func (s *BackupStore) CreateRun(ctx context.Context, run *BackupRun) error

func (*BackupStore) DeleteItemsByRunIDs added in v1.5.0

func (s *BackupStore) DeleteItemsByRunIDs(ctx context.Context, runIDs []int64) error

func (*BackupStore) DeleteRun added in v1.5.0

func (s *BackupStore) DeleteRun(ctx context.Context, runID int64) error

func (*BackupStore) DeleteRunsByIDs added in v1.5.0

func (s *BackupStore) DeleteRunsByIDs(ctx context.Context, runIDs []int64) error

func (*BackupStore) DeleteRunsOlderThan added in v1.5.0

func (s *BackupStore) DeleteRunsOlderThan(ctx context.Context, instanceID int, kind BackupRunKind, keep int) ([]int64, error)

func (*BackupStore) FindCachedTorrentBlob added in v1.5.0

func (s *BackupStore) FindCachedTorrentBlob(ctx context.Context, instanceID int, hash string) (*string, error)

func (*BackupStore) FindIncompleteRuns added in v1.6.0

func (s *BackupStore) FindIncompleteRuns(ctx context.Context) ([]*BackupRun, error)

FindIncompleteRuns returns all backup runs that are in pending or running status. These are runs that were interrupted by a restart or crash.

func (*BackupStore) GetInstanceName added in v1.5.0

func (s *BackupStore) GetInstanceName(ctx context.Context, instanceID int) (string, error)

func (*BackupStore) GetItemByHash added in v1.5.0

func (s *BackupStore) GetItemByHash(ctx context.Context, runID int64, hash string) (*BackupItem, error)

func (*BackupStore) GetRun added in v1.5.0

func (s *BackupStore) GetRun(ctx context.Context, runID int64) (*BackupRun, error)

func (*BackupStore) GetRuns added in v1.8.0

func (s *BackupStore) GetRuns(ctx context.Context, runIDs []int64) ([]*BackupRun, error)

func (*BackupStore) GetSettings added in v1.5.0

func (s *BackupStore) GetSettings(ctx context.Context, instanceID int) (*BackupSettings, error)

func (*BackupStore) InsertItems added in v1.5.0

func (s *BackupStore) InsertItems(ctx context.Context, runID int64, items []BackupItem) error

func (*BackupStore) LatestRunByKind added in v1.5.0

func (s *BackupStore) LatestRunByKind(ctx context.Context, instanceID int, kind BackupRunKind) (*BackupRun, error)

func (*BackupStore) ListEnabledSettings added in v1.5.0

func (s *BackupStore) ListEnabledSettings(ctx context.Context) ([]*BackupSettings, error)

func (*BackupStore) ListItems added in v1.5.0

func (s *BackupStore) ListItems(ctx context.Context, runID int64) ([]*BackupItem, error)

func (*BackupStore) ListItemsForRuns added in v1.8.0

func (s *BackupStore) ListItemsForRuns(ctx context.Context, runIDs []int64) ([]*BackupItem, error)

func (*BackupStore) ListRunIDs added in v1.5.0

func (s *BackupStore) ListRunIDs(ctx context.Context, instanceID int) ([]int64, error)

func (*BackupStore) ListRuns added in v1.5.0

func (s *BackupStore) ListRuns(ctx context.Context, instanceID int, limit, offset int) ([]*BackupRun, error)

func (*BackupStore) ListRunsByKind added in v1.5.0

func (s *BackupStore) ListRunsByKind(ctx context.Context, instanceID int, kind BackupRunKind, limit int) ([]*BackupRun, error)

func (*BackupStore) RemoveFailedRunsBefore added in v1.5.0

func (s *BackupStore) RemoveFailedRunsBefore(ctx context.Context, cutoff time.Time) (int64, error)

RemoveFailedRunsBefore deletes failed runs older than the provided cutoff and returns the number of rows affected.

func (*BackupStore) UpdateMultipleRunsStatus added in v1.7.0

func (s *BackupStore) UpdateMultipleRunsStatus(ctx context.Context, runIDs []int64, status BackupRunStatus, completedAt *time.Time, errorMessage *string) error

UpdateMultipleRunsStatus updates the status of multiple backup runs in a single transaction

func (*BackupStore) UpdateRunMetadata added in v1.5.0

func (s *BackupStore) UpdateRunMetadata(ctx context.Context, runID int64, updateFn func(*BackupRun) error) error

func (*BackupStore) UpsertSettings added in v1.5.0

func (s *BackupStore) UpsertSettings(ctx context.Context, settings *BackupSettings) error

type CategorySnapshot added in v1.5.0

type CategorySnapshot struct {
	SavePath string `json:"savePath,omitempty"`
}

type ClientAPIKey added in v1.0.0

type ClientAPIKey struct {
	ID         int        `json:"id"`
	KeyHash    string     `json:"-"`
	ClientName string     `json:"clientName"`
	InstanceID int        `json:"instanceId"`
	CreatedAt  time.Time  `json:"createdAt"`
	LastUsedAt *time.Time `json:"lastUsedAt,omitempty"`
}

type ClientAPIKeyStore added in v1.0.0

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

func NewClientAPIKeyStore added in v1.0.0

func NewClientAPIKeyStore(db dbinterface.Querier) *ClientAPIKeyStore

func (*ClientAPIKeyStore) Create added in v1.0.0

func (s *ClientAPIKeyStore) Create(ctx context.Context, clientName string, instanceID int) (string, *ClientAPIKey, error)

func (*ClientAPIKeyStore) Delete added in v1.0.0

func (s *ClientAPIKeyStore) Delete(ctx context.Context, id int) error

func (*ClientAPIKeyStore) DeleteByInstanceID added in v1.0.0

func (s *ClientAPIKeyStore) DeleteByInstanceID(ctx context.Context, instanceID int) error

func (*ClientAPIKeyStore) GetAll added in v1.0.0

func (s *ClientAPIKeyStore) GetAll(ctx context.Context) ([]*ClientAPIKey, error)

func (*ClientAPIKeyStore) GetByKeyHash added in v1.0.0

func (s *ClientAPIKeyStore) GetByKeyHash(ctx context.Context, keyHash string) (*ClientAPIKey, error)

func (*ClientAPIKeyStore) UpdateLastUsed added in v1.0.0

func (s *ClientAPIKeyStore) UpdateLastUsed(ctx context.Context, keyHash string) error

func (*ClientAPIKeyStore) ValidateKey added in v1.0.0

func (s *ClientAPIKeyStore) ValidateKey(ctx context.Context, rawKey string) (*ClientAPIKey, error)

type CompletionFilterProvider added in v1.10.0

type CompletionFilterProvider interface {
	GetCategories() []string
	GetTags() []string
	GetExcludeCategories() []string
	GetExcludeTags() []string
}

CompletionFilterProvider defines the interface for types that provide completion filter fields. Used by InstanceCrossSeedCompletionSettings for per-instance completion configuration.

type CrossSeedAutomationSettings added in v1.8.0

type CrossSeedAutomationSettings struct {
	// RSS Automation settings
	Enabled            bool     `json:"enabled"`            // Enable/disable RSS automation
	RunIntervalMinutes int      `json:"runIntervalMinutes"` // RSS: interval between RSS feed polls (min: 30 minutes, default: 120)
	StartPaused        bool     `json:"startPaused"`        // RSS: start added torrents paused
	Category           *string  `json:"category,omitempty"` // RSS: category for added torrents
	IgnorePatterns     []string `json:"ignorePatterns"`     // RSS: file patterns to ignore
	TargetInstanceIDs  []int    `json:"targetInstanceIds"`  // RSS: instances to add cross-seeds to
	TargetIndexerIDs   []int    `json:"targetIndexerIds"`   // RSS: indexers to poll for RSS feeds
	MaxResultsPerRun   int      `json:"maxResultsPerRun"`   // Deprecated: automation processes full feeds; retained for backward compatibility

	// RSS source filtering: filter which LOCAL torrents are considered when checking RSS feeds.
	// Empty arrays mean "all" (no filtering).
	RSSSourceCategories        []string `json:"rssSourceCategories"`        // Only match against torrents in these categories
	RSSSourceTags              []string `json:"rssSourceTags"`              // Only match against torrents with these tags
	RSSSourceExcludeCategories []string `json:"rssSourceExcludeCategories"` // Skip torrents in these categories
	RSSSourceExcludeTags       []string `json:"rssSourceExcludeTags"`       // Skip torrents with these tags

	// Webhook source filtering: filter which LOCAL torrents are considered when checking webhook requests.
	// Empty arrays mean "all" (no filtering).
	WebhookSourceCategories        []string `json:"webhookSourceCategories"`        // Only match against torrents in these categories
	WebhookSourceTags              []string `json:"webhookSourceTags"`              // Only match against torrents with these tags
	WebhookSourceExcludeCategories []string `json:"webhookSourceExcludeCategories"` // Skip torrents in these categories
	WebhookSourceExcludeTags       []string `json:"webhookSourceExcludeTags"`       // Skip torrents with these tags

	// Global cross-seed settings (apply to both RSS Automation and Seeded Torrent Search)
	FindIndividualEpisodes       bool    `json:"findIndividualEpisodes"`       // Match season packs with individual episodes
	SizeMismatchTolerancePercent float64 `json:"sizeMismatchTolerancePercent"` // Size tolerance for matching (default: 5%)
	UseCategoryFromIndexer       bool    `json:"useCategoryFromIndexer"`       // Use indexer name as category for cross-seeds
	RunExternalProgramID         *int    `json:"runExternalProgramId"`         // Optional external program to run after successful cross-seed injection

	// Source-specific tagging: tags applied based on how the cross-seed was discovered.
	// Each defaults to ["cross-seed"]. Users can add source-specific tags like "rss", "seeded-search", etc.
	RSSAutomationTags    []string `json:"rssAutomationTags"`    // Tags for RSS automation results
	SeededSearchTags     []string `json:"seededSearchTags"`     // Tags for seeded torrent search results
	CompletionSearchTags []string `json:"completionSearchTags"` // Tags for completion-triggered search results
	WebhookTags          []string `json:"webhookTags"`          // Tags for /apply webhook results
	InheritSourceTags    bool     `json:"inheritSourceTags"`    // Also copy tags from the matched source torrent

	// Category isolation: add .cross suffix to prevent *arr import loops
	UseCrossCategorySuffix bool `json:"useCrossCategorySuffix"` // Add .cross suffix to categories (e.g., movies → movies.cross)

	// Skip auto-resume settings per source mode.
	// When enabled, torrents remain paused after hash check instead of auto-resuming.
	SkipAutoResumeRSS          bool `json:"skipAutoResumeRss"`          // Skip auto-resume for RSS automation results
	SkipAutoResumeSeededSearch bool `json:"skipAutoResumeSeededSearch"` // Skip auto-resume for seeded torrent search results
	SkipAutoResumeCompletion   bool `json:"skipAutoResumeCompletion"`   // Skip auto-resume for completion-triggered search results
	SkipAutoResumeWebhook      bool `json:"skipAutoResumeWebhook"`      // Skip auto-resume for /apply webhook results

	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

CrossSeedAutomationSettings controls automatic cross-seed behaviour. Contains both RSS Automation-specific settings and global cross-seed settings.

func DefaultCrossSeedAutomationSettings added in v1.8.0

func DefaultCrossSeedAutomationSettings() *CrossSeedAutomationSettings

DefaultCrossSeedAutomationSettings returns sensible defaults for RSS automation. RSS automation is disabled by default with a 2-hour interval.

type CrossSeedFeedItem added in v1.8.0

type CrossSeedFeedItem struct {
	GUID        string                  `json:"guid"`
	IndexerID   int                     `json:"indexerId"`
	Title       string                  `json:"title"`
	FirstSeenAt time.Time               `json:"firstSeenAt"`
	LastSeenAt  time.Time               `json:"lastSeenAt"`
	LastStatus  CrossSeedFeedItemStatus `json:"lastStatus"`
	LastRunID   *int64                  `json:"lastRunId,omitempty"`
	InfoHash    *string                 `json:"infoHash,omitempty"`
}

CrossSeedFeedItem tracks GUIDs pulled from indexers to avoid duplicates.

type CrossSeedFeedItemStatus added in v1.8.0

type CrossSeedFeedItemStatus string

CrossSeedFeedItemStatus tracks processing state for feed items.

const (
	CrossSeedFeedItemStatusPending   CrossSeedFeedItemStatus = "pending"
	CrossSeedFeedItemStatusProcessed CrossSeedFeedItemStatus = "processed"
	CrossSeedFeedItemStatusSkipped   CrossSeedFeedItemStatus = "skipped"
	CrossSeedFeedItemStatusFailed    CrossSeedFeedItemStatus = "failed"
)

type CrossSeedRun added in v1.8.0

type CrossSeedRun struct {
	ID              int64                `json:"id"`
	TriggeredBy     string               `json:"triggeredBy"`
	Mode            CrossSeedRunMode     `json:"mode"`
	Status          CrossSeedRunStatus   `json:"status"`
	StartedAt       time.Time            `json:"startedAt"`
	CompletedAt     *time.Time           `json:"completedAt,omitempty"`
	TotalFeedItems  int                  `json:"totalFeedItems"`
	CandidatesFound int                  `json:"candidatesFound"`
	TorrentsAdded   int                  `json:"torrentsAdded"`
	TorrentsFailed  int                  `json:"torrentsFailed"`
	TorrentsSkipped int                  `json:"torrentsSkipped"`
	Message         *string              `json:"message,omitempty"`
	ErrorMessage    *string              `json:"errorMessage,omitempty"`
	Results         []CrossSeedRunResult `json:"results,omitempty"`
	CreatedAt       time.Time            `json:"createdAt"`
}

CrossSeedRun stores the persisted automation run metadata.

type CrossSeedRunMode added in v1.8.0

type CrossSeedRunMode string

CrossSeedRunMode indicates how the run was triggered.

const (
	CrossSeedRunModeAuto   CrossSeedRunMode = "auto"
	CrossSeedRunModeManual CrossSeedRunMode = "manual"
)

type CrossSeedRunResult added in v1.8.0

type CrossSeedRunResult struct {
	InstanceID         int     `json:"instanceId"`
	InstanceName       string  `json:"instanceName"`
	IndexerName        string  `json:"indexerName,omitempty"`
	Success            bool    `json:"success"`
	Status             string  `json:"status"`
	Message            string  `json:"message,omitempty"`
	MatchedTorrentHash *string `json:"matchedTorrentHash,omitempty"`
	MatchedTorrentName *string `json:"matchedTorrentName,omitempty"`
}

CrossSeedRunResult summarises the outcome for a single instance.

type CrossSeedRunStatus added in v1.8.0

type CrossSeedRunStatus string

CrossSeedRunStatus indicates the outcome of an automation run.

const (
	CrossSeedRunStatusPending CrossSeedRunStatus = "pending"
	CrossSeedRunStatusRunning CrossSeedRunStatus = "running"
	CrossSeedRunStatusSuccess CrossSeedRunStatus = "success"
	CrossSeedRunStatusPartial CrossSeedRunStatus = "partial"
	CrossSeedRunStatusFailed  CrossSeedRunStatus = "failed"
)

type CrossSeedSearchFilters added in v1.8.0

type CrossSeedSearchFilters struct {
	Categories []string `json:"categories"`
	Tags       []string `json:"tags"`
}

CrossSeedSearchFilters capture how torrents are selected for automated search runs.

type CrossSeedSearchResult added in v1.8.0

type CrossSeedSearchResult struct {
	TorrentHash  string    `json:"torrentHash"`
	TorrentName  string    `json:"torrentName"`
	IndexerName  string    `json:"indexerName"`
	ReleaseTitle string    `json:"releaseTitle"`
	Added        bool      `json:"added"`
	Message      string    `json:"message,omitempty"`
	ProcessedAt  time.Time `json:"processedAt"`
}

CrossSeedSearchResult records the outcome of processing a single torrent during a search run.

type CrossSeedSearchRun added in v1.8.0

type CrossSeedSearchRun struct {
	ID              int64                    `json:"id"`
	InstanceID      int                      `json:"instanceId"`
	Status          CrossSeedSearchRunStatus `json:"status"`
	StartedAt       time.Time                `json:"startedAt"`
	CompletedAt     *time.Time               `json:"completedAt,omitempty"`
	TotalTorrents   int                      `json:"totalTorrents"`
	Processed       int                      `json:"processed"`
	TorrentsAdded   int                      `json:"torrentsAdded"`
	TorrentsFailed  int                      `json:"torrentsFailed"`
	TorrentsSkipped int                      `json:"torrentsSkipped"`
	Message         *string                  `json:"message,omitempty"`
	ErrorMessage    *string                  `json:"errorMessage,omitempty"`
	Filters         CrossSeedSearchFilters   `json:"filters"`
	IndexerIDs      []int                    `json:"indexerIds"`
	IntervalSeconds int                      `json:"intervalSeconds"`
	CooldownMinutes int                      `json:"cooldownMinutes"`
	Results         []CrossSeedSearchResult  `json:"results"`
	CreatedAt       time.Time                `json:"createdAt"`
}

CrossSeedSearchRun stores metadata for library search automation runs.

type CrossSeedSearchRunStatus added in v1.8.0

type CrossSeedSearchRunStatus string

CrossSeedSearchRunStatus represents the lifecycle state of an automated search pass.

const (
	CrossSeedSearchRunStatusRunning  CrossSeedSearchRunStatus = "running"
	CrossSeedSearchRunStatusSuccess  CrossSeedSearchRunStatus = "success"
	CrossSeedSearchRunStatusFailed   CrossSeedSearchRunStatus = "failed"
	CrossSeedSearchRunStatusCanceled CrossSeedSearchRunStatus = "canceled"
)

type CrossSeedSearchSettings added in v1.8.0

type CrossSeedSearchSettings struct {
	InstanceID      *int      `json:"instanceId"`
	Categories      []string  `json:"categories"`
	Tags            []string  `json:"tags"`
	IndexerIDs      []int     `json:"indexerIds"`
	IntervalSeconds int       `json:"intervalSeconds"`
	CooldownMinutes int       `json:"cooldownMinutes"`
	CreatedAt       time.Time `json:"createdAt"`
	UpdatedAt       time.Time `json:"updatedAt"`
}

CrossSeedSearchSettings stores defaults for manual seeded torrent searches.

func DefaultCrossSeedSearchSettings added in v1.8.0

func DefaultCrossSeedSearchSettings() *CrossSeedSearchSettings

DefaultCrossSeedSearchSettings returns defaults for seeded torrent searches.

type CrossSeedStore added in v1.8.0

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

CrossSeedStore persists automation settings, runs, and feed items.

func NewCrossSeedStore added in v1.8.0

func NewCrossSeedStore(db dbinterface.Querier) *CrossSeedStore

NewCrossSeedStore constructs a new automation store.

func (*CrossSeedStore) CreateRun added in v1.8.0

func (s *CrossSeedStore) CreateRun(ctx context.Context, run *CrossSeedRun) (*CrossSeedRun, error)

CreateRun inserts a new automation run record.

func (*CrossSeedStore) CreateSearchRun added in v1.8.0

func (s *CrossSeedStore) CreateSearchRun(ctx context.Context, run *CrossSeedSearchRun) (*CrossSeedSearchRun, error)

CreateSearchRun inserts a new record for a search automation run.

func (*CrossSeedStore) GetLatestRun added in v1.8.0

func (s *CrossSeedStore) GetLatestRun(ctx context.Context) (*CrossSeedRun, error)

GetLatestRun returns the most recent automation run.

func (*CrossSeedStore) GetRun added in v1.8.0

func (s *CrossSeedStore) GetRun(ctx context.Context, id int64) (*CrossSeedRun, error)

GetRun fetches a single run by ID.

func (*CrossSeedStore) GetSearchHistory added in v1.8.0

func (s *CrossSeedStore) GetSearchHistory(ctx context.Context, instanceID int, torrentHash string) (time.Time, bool, error)

GetSearchHistory returns the last time a torrent was searched.

func (*CrossSeedStore) GetSearchRun added in v1.8.0

func (s *CrossSeedStore) GetSearchRun(ctx context.Context, id int64) (*CrossSeedSearchRun, error)

GetSearchRun loads a specific search run by ID.

func (*CrossSeedStore) GetSearchSettings added in v1.8.0

func (s *CrossSeedStore) GetSearchSettings(ctx context.Context) (*CrossSeedSearchSettings, error)

GetSearchSettings returns the stored seeded search defaults, or defaults when unset.

func (*CrossSeedStore) GetSettings added in v1.8.0

GetSettings returns the current automation settings or defaults.

func (*CrossSeedStore) HasProcessedFeedItem added in v1.8.0

func (s *CrossSeedStore) HasProcessedFeedItem(ctx context.Context, guid string, indexerID int) (bool, CrossSeedFeedItemStatus, error)

HasProcessedFeedItem reports whether a GUID/indexer pair has been handled.

func (*CrossSeedStore) ListRuns added in v1.8.0

func (s *CrossSeedStore) ListRuns(ctx context.Context, limit, offset int) ([]*CrossSeedRun, error)

ListRuns returns automation run history.

func (*CrossSeedStore) ListSearchRuns added in v1.8.0

func (s *CrossSeedStore) ListSearchRuns(ctx context.Context, instanceID, limit, offset int) ([]*CrossSeedSearchRun, error)

ListSearchRuns returns search automation history for an instance.

func (*CrossSeedStore) MarkFeedItem added in v1.8.0

func (s *CrossSeedStore) MarkFeedItem(ctx context.Context, item *CrossSeedFeedItem) error

MarkFeedItem updates the state of a feed item.

func (*CrossSeedStore) PruneFeedItems added in v1.8.0

func (s *CrossSeedStore) PruneFeedItems(ctx context.Context, olderThan time.Time) (int64, error)

PruneFeedItems removes processed feed items older than the provided cutoff.

func (*CrossSeedStore) UpdateRun added in v1.8.0

func (s *CrossSeedStore) UpdateRun(ctx context.Context, run *CrossSeedRun) (*CrossSeedRun, error)

UpdateRun updates an existing run with final statistics.

func (*CrossSeedStore) UpdateSearchRun added in v1.8.0

func (s *CrossSeedStore) UpdateSearchRun(ctx context.Context, run *CrossSeedSearchRun) (*CrossSeedSearchRun, error)

UpdateSearchRun updates persisted metadata for a search run.

func (*CrossSeedStore) UpsertSearchHistory added in v1.8.0

func (s *CrossSeedStore) UpsertSearchHistory(ctx context.Context, instanceID int, torrentHash string, searchedAt time.Time) error

UpsertSearchHistory updates the last searched timestamp for a torrent on an instance.

func (*CrossSeedStore) UpsertSearchSettings added in v1.8.0

func (s *CrossSeedStore) UpsertSearchSettings(ctx context.Context, settings *CrossSeedSearchSettings) (*CrossSeedSearchSettings, error)

UpsertSearchSettings saves seeded search defaults.

func (*CrossSeedStore) UpsertSettings added in v1.8.0

UpsertSettings saves automation settings and returns the updated value.

type DashboardSettings added in v1.9.0

type DashboardSettings struct {
	ID                           int             `json:"id"`
	UserID                       int             `json:"userId"`
	SectionVisibility            map[string]bool `json:"sectionVisibility"`
	SectionOrder                 []string        `json:"sectionOrder"`
	SectionCollapsed             map[string]bool `json:"sectionCollapsed"`
	TrackerBreakdownSortColumn   string          `json:"trackerBreakdownSortColumn"`
	TrackerBreakdownSortDir      string          `json:"trackerBreakdownSortDirection"`
	TrackerBreakdownItemsPerPage int             `json:"trackerBreakdownItemsPerPage"`
	CreatedAt                    time.Time       `json:"createdAt"`
	UpdatedAt                    time.Time       `json:"updatedAt"`
}

type DashboardSettingsInput added in v1.9.0

type DashboardSettingsInput struct {
	SectionVisibility            map[string]bool `json:"sectionVisibility,omitempty"`
	SectionOrder                 []string        `json:"sectionOrder,omitempty"`
	SectionCollapsed             map[string]bool `json:"sectionCollapsed,omitempty"`
	TrackerBreakdownSortColumn   string          `json:"trackerBreakdownSortColumn,omitempty"`
	TrackerBreakdownSortDir      string          `json:"trackerBreakdownSortDirection,omitempty"`
	TrackerBreakdownItemsPerPage int             `json:"trackerBreakdownItemsPerPage,omitempty"`
}

type DashboardSettingsStore added in v1.9.0

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

func NewDashboardSettingsStore added in v1.9.0

func NewDashboardSettingsStore(db dbinterface.Querier) *DashboardSettingsStore

func (*DashboardSettingsStore) GetByUserID added in v1.9.0

func (s *DashboardSettingsStore) GetByUserID(ctx context.Context, userID int) (*DashboardSettings, error)

GetByUserID returns settings for a user, creating defaults if none exist

func (*DashboardSettingsStore) Update added in v1.9.0

Update updates settings for a user (partial update - merges with existing)

type ExternalProgram added in v1.7.0

type ExternalProgram struct {
	ID           int           `json:"id"`
	Name         string        `json:"name"`
	Path         string        `json:"path"`
	ArgsTemplate string        `json:"args_template"`
	Enabled      bool          `json:"enabled"`
	UseTerminal  bool          `json:"use_terminal"`
	PathMappings []PathMapping `json:"path_mappings"`
	CreatedAt    time.Time     `json:"created_at"`
	UpdatedAt    time.Time     `json:"updated_at"`
}

ExternalProgram represents a configured external program that can be executed from the torrent context menu

type ExternalProgramCreate added in v1.7.0

type ExternalProgramCreate struct {
	Name         string        `json:"name"`
	Path         string        `json:"path"`
	ArgsTemplate string        `json:"args_template"`
	Enabled      bool          `json:"enabled"`
	UseTerminal  bool          `json:"use_terminal"`
	PathMappings []PathMapping `json:"path_mappings"`
}

ExternalProgramCreate represents the data needed to create a new external program

type ExternalProgramExecute added in v1.7.0

type ExternalProgramExecute struct {
	ProgramID  int      `json:"program_id"`
	InstanceID int      `json:"instance_id"`
	Hashes     []string `json:"hashes"`
}

ExternalProgramExecute represents a request to execute an external program with torrent data

type ExternalProgramStore added in v1.7.0

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

func NewExternalProgramStore added in v1.7.0

func NewExternalProgramStore(db dbinterface.Querier) *ExternalProgramStore

func (*ExternalProgramStore) Create added in v1.7.0

func (*ExternalProgramStore) Delete added in v1.7.0

func (s *ExternalProgramStore) Delete(ctx context.Context, id int) error

func (*ExternalProgramStore) GetByID added in v1.7.0

func (s *ExternalProgramStore) GetByID(ctx context.Context, id int) (*ExternalProgram, error)

func (*ExternalProgramStore) List added in v1.7.0

func (*ExternalProgramStore) ListEnabled added in v1.7.0

func (s *ExternalProgramStore) ListEnabled(ctx context.Context) ([]*ExternalProgram, error)

func (*ExternalProgramStore) Update added in v1.7.0

type ExternalProgramUpdate added in v1.7.0

type ExternalProgramUpdate struct {
	Name         string        `json:"name"`
	Path         string        `json:"path"`
	ArgsTemplate string        `json:"args_template"`
	Enabled      bool          `json:"enabled"`
	UseTerminal  bool          `json:"use_terminal"`
	PathMappings []PathMapping `json:"path_mappings"`
}

ExternalProgramUpdate represents the data needed to update an external program

type Instance

type Instance struct {
	ID                     int     `json:"id"`
	Name                   string  `json:"name"`
	Host                   string  `json:"host"`
	Username               string  `json:"username"`
	PasswordEncrypted      string  `json:"-"`
	BasicUsername          *string `json:"basic_username,omitempty"`
	BasicPasswordEncrypted *string `json:"-"`
	TLSSkipVerify          bool    `json:"tlsSkipVerify"`
	SortOrder              int     `json:"sortOrder"`
	IsActive               bool    `json:"isActive"`
}

func (Instance) MarshalJSON added in v1.0.0

func (i Instance) MarshalJSON() ([]byte, error)

func (*Instance) UnmarshalJSON added in v1.0.0

func (i *Instance) UnmarshalJSON(data []byte) error

type InstanceCrossSeedCompletionSettings added in v1.10.0

type InstanceCrossSeedCompletionSettings struct {
	InstanceID        int       `json:"instanceId"`
	Enabled           bool      `json:"enabled"`
	Categories        []string  `json:"categories"`
	Tags              []string  `json:"tags"`
	ExcludeCategories []string  `json:"excludeCategories"`
	ExcludeTags       []string  `json:"excludeTags"`
	UpdatedAt         time.Time `json:"updatedAt"`
}

InstanceCrossSeedCompletionSettings stores per-instance cross-seed completion configuration.

func DefaultInstanceCrossSeedCompletionSettings added in v1.10.0

func DefaultInstanceCrossSeedCompletionSettings(instanceID int) *InstanceCrossSeedCompletionSettings

DefaultInstanceCrossSeedCompletionSettings returns default values for a new instance. Completion is disabled by default for safety.

func (*InstanceCrossSeedCompletionSettings) GetCategories added in v1.10.0

func (s *InstanceCrossSeedCompletionSettings) GetCategories() []string

GetCategories returns the categories filter.

func (*InstanceCrossSeedCompletionSettings) GetExcludeCategories added in v1.10.0

func (s *InstanceCrossSeedCompletionSettings) GetExcludeCategories() []string

GetExcludeCategories returns the excluded categories filter.

func (*InstanceCrossSeedCompletionSettings) GetExcludeTags added in v1.10.0

func (s *InstanceCrossSeedCompletionSettings) GetExcludeTags() []string

GetExcludeTags returns the excluded tags filter.

func (*InstanceCrossSeedCompletionSettings) GetTags added in v1.10.0

GetTags returns the tags filter.

type InstanceCrossSeedCompletionStore added in v1.10.0

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

InstanceCrossSeedCompletionStore manages persistence for InstanceCrossSeedCompletionSettings.

func NewInstanceCrossSeedCompletionStore added in v1.10.0

func NewInstanceCrossSeedCompletionStore(db dbinterface.Querier) *InstanceCrossSeedCompletionStore

NewInstanceCrossSeedCompletionStore creates a new store.

func (*InstanceCrossSeedCompletionStore) Get added in v1.10.0

Get returns settings for an instance, falling back to defaults if missing.

func (*InstanceCrossSeedCompletionStore) List added in v1.10.0

List returns settings for all instances that have overrides. Instances without overrides are omitted.

func (*InstanceCrossSeedCompletionStore) Upsert added in v1.10.0

Upsert saves settings for an instance, creating or updating as needed.

type InstanceError added in v1.0.0

type InstanceError struct {
	ID           int       `json:"id"`
	InstanceID   int       `json:"instanceId"`
	ErrorType    string    `json:"errorType"`
	ErrorMessage string    `json:"errorMessage"`
	OccurredAt   time.Time `json:"occurredAt"`
}

type InstanceErrorStore added in v1.0.0

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

func NewInstanceErrorStore added in v1.0.0

func NewInstanceErrorStore(db dbinterface.Querier) *InstanceErrorStore

func (*InstanceErrorStore) ClearErrors added in v1.0.0

func (s *InstanceErrorStore) ClearErrors(ctx context.Context, instanceID int) error

ClearErrors removes all errors for an instance (called on successful connection)

func (*InstanceErrorStore) GetRecentErrors added in v1.0.0

func (s *InstanceErrorStore) GetRecentErrors(ctx context.Context, instanceID int, limit int) ([]InstanceError, error)

GetRecentErrors retrieves the last N errors for an instance

func (*InstanceErrorStore) RecordError added in v1.0.0

func (s *InstanceErrorStore) RecordError(ctx context.Context, instanceID int, err error) error

RecordError stores an error for an instance with simple deduplication

type InstanceReannounceSettings added in v1.8.0

type InstanceReannounceSettings struct {
	InstanceID                int       `json:"instanceId"`
	Enabled                   bool      `json:"enabled"`
	InitialWaitSeconds        int       `json:"initialWaitSeconds"`
	ReannounceIntervalSeconds int       `json:"reannounceIntervalSeconds"`
	MaxAgeSeconds             int       `json:"maxAgeSeconds"`
	MaxRetries                int       `json:"maxRetries"`
	Aggressive                bool      `json:"aggressive"`
	MonitorAll                bool      `json:"monitorAll"`
	ExcludeCategories         bool      `json:"excludeCategories"`
	Categories                []string  `json:"categories"`
	ExcludeTags               bool      `json:"excludeTags"`
	Tags                      []string  `json:"tags"`
	ExcludeTrackers           bool      `json:"excludeTrackers"`
	Trackers                  []string  `json:"trackers"`
	UpdatedAt                 time.Time `json:"updatedAt"`
}

InstanceReannounceSettings stores per-instance tracker reannounce configuration.

func DefaultInstanceReannounceSettings added in v1.8.0

func DefaultInstanceReannounceSettings(instanceID int) *InstanceReannounceSettings

DefaultInstanceReannounceSettings returns default values for a new instance.

type InstanceReannounceStore added in v1.8.0

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

InstanceReannounceStore manages persistence for InstanceReannounceSettings.

func NewInstanceReannounceStore added in v1.8.0

func NewInstanceReannounceStore(db dbinterface.Querier) *InstanceReannounceStore

NewInstanceReannounceStore creates a new store.

func (*InstanceReannounceStore) Get added in v1.8.0

Get returns settings for an instance, falling back to defaults if missing.

func (*InstanceReannounceStore) List added in v1.8.0

List returns settings for all instances that have overrides. Instances without overrides are omitted.

func (*InstanceReannounceStore) Upsert added in v1.8.0

Upsert saves settings for an instance, creating or updating as needed.

type InstanceStore

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

func NewInstanceStore

func NewInstanceStore(db dbinterface.Querier, encryptionKey []byte) (*InstanceStore, error)

func (*InstanceStore) Create

func (s *InstanceStore) Create(ctx context.Context, name, rawHost, username, password string, basicUsername, basicPassword *string, tlsSkipVerify bool) (*Instance, error)

func (*InstanceStore) Delete

func (s *InstanceStore) Delete(ctx context.Context, id int) error

func (*InstanceStore) Get

func (s *InstanceStore) Get(ctx context.Context, id int) (*Instance, error)

func (*InstanceStore) GetDecryptedBasicPassword

func (s *InstanceStore) GetDecryptedBasicPassword(instance *Instance) (*string, error)

GetDecryptedBasicPassword returns the decrypted basic auth password for an instance

func (*InstanceStore) GetDecryptedPassword

func (s *InstanceStore) GetDecryptedPassword(instance *Instance) (string, error)

GetDecryptedPassword returns the decrypted password for an instance

func (*InstanceStore) List

func (s *InstanceStore) List(ctx context.Context) ([]*Instance, error)

func (*InstanceStore) SetActiveState added in v1.8.0

func (s *InstanceStore) SetActiveState(ctx context.Context, id int, active bool) (*Instance, error)

func (*InstanceStore) Update

func (s *InstanceStore) Update(ctx context.Context, id int, name, rawHost, username, password string, basicUsername, basicPassword *string, tlsSkipVerify *bool) (*Instance, error)

func (*InstanceStore) UpdateOrder added in v1.7.0

func (s *InstanceStore) UpdateOrder(ctx context.Context, instanceIDs []int) error

type LicenseInfo added in v1.0.0

type LicenseInfo struct {
	Key          string     `json:"key"`
	ProductName  string     `json:"productName"`
	CustomerID   string     `json:"customerId"`
	ProductID    string     `json:"productId"`
	ExpiresAt    *time.Time `json:"expiresAt,omitempty"`
	Valid        bool       `json:"valid"`
	ErrorMessage string     `json:"errorMessage,omitempty"`
}

LicenseInfo contains license validation information

type PathMapping added in v1.7.0

type PathMapping struct {
	From string `json:"from"` // Remote path prefix
	To   string `json:"to"`   // Local path prefix
}

PathMapping represents a path mapping from remote to local

type ProductLicense added in v1.0.0

type ProductLicense struct {
	ID                int        `json:"id"`
	LicenseKey        string     `json:"licenseKey"`
	ProductName       string     `json:"productName"`
	Status            string     `json:"status"`
	ActivatedAt       time.Time  `json:"activatedAt"`
	ExpiresAt         *time.Time `json:"expiresAt,omitempty"`
	LastValidated     time.Time  `json:"lastValidated"`
	PolarCustomerID   *string    `json:"polarCustomerId,omitempty"`
	PolarProductID    *string    `json:"polarProductId,omitempty"`
	PolarActivationID string     `json:"polarActivationId,omitempty"`
	Username          string     `json:"username"`
	CreatedAt         time.Time  `json:"createdAt"`
	UpdatedAt         time.Time  `json:"updatedAt"`
}

ProductLicense represents a product license in the database

type TorznabBackend added in v1.8.0

type TorznabBackend string

TorznabBackend represents the backend implementation used to access a Torznab indexer.

const (
	// TorznabBackendJackett routes requests through a Jackett instance.
	TorznabBackendJackett TorznabBackend = "jackett"
	// TorznabBackendProwlarr routes requests through a Prowlarr instance.
	TorznabBackendProwlarr TorznabBackend = "prowlarr"
	// TorznabBackendNative talks directly to a tracker-provided Torznab/Newznab endpoint.
	TorznabBackendNative TorznabBackend = "native"
)

func MustTorznabBackend added in v1.8.0

func MustTorznabBackend(value string) TorznabBackend

MustTorznabBackend parses backend and panics on error (useful for defaults).

func ParseTorznabBackend added in v1.8.0

func ParseTorznabBackend(value string) (TorznabBackend, error)

ParseTorznabBackend validates and normalizes a backend string.

type TorznabIndexer added in v1.8.0

type TorznabIndexer struct {
	ID              int                      `json:"id"`
	Name            string                   `json:"name"`
	BaseURL         string                   `json:"base_url"`
	IndexerID       string                   `json:"indexer_id"` // Jackett/Prowlarr indexer ID (e.g., "aither")
	Backend         TorznabBackend           `json:"backend"`
	APIKeyEncrypted string                   `json:"-"`
	Enabled         bool                     `json:"enabled"`
	Priority        int                      `json:"priority"`
	TimeoutSeconds  int                      `json:"timeout_seconds"`
	Capabilities    []string                 `json:"capabilities"`
	Categories      []TorznabIndexerCategory `json:"categories"`
	LastTestAt      *time.Time               `json:"last_test_at,omitempty"`
	LastTestStatus  string                   `json:"last_test_status"`
	LastTestError   *string                  `json:"last_test_error,omitempty"`
	CreatedAt       time.Time                `json:"created_at"`
	UpdatedAt       time.Time                `json:"updated_at"`
}

TorznabIndexer represents a Torznab API indexer (Jackett, Prowlarr, etc.)

type TorznabIndexerCapability added in v1.8.0

type TorznabIndexerCapability struct {
	IndexerID      int    `json:"indexer_id"`
	CapabilityType string `json:"capability_type"`
}

TorznabIndexerCapability represents a search capability

type TorznabIndexerCategory added in v1.8.0

type TorznabIndexerCategory struct {
	IndexerID      int    `json:"indexer_id"`
	CategoryID     int    `json:"category_id"`
	CategoryName   string `json:"category_name"`
	ParentCategory *int   `json:"parent_category_id,omitempty"`
}

TorznabIndexerCategory represents a category supported by an indexer

type TorznabIndexerCooldown added in v1.8.0

type TorznabIndexerCooldown struct {
	IndexerID int           `json:"indexer_id"`
	ResumeAt  time.Time     `json:"resume_at"`
	Cooldown  time.Duration `json:"cooldown"`
	Reason    string        `json:"reason,omitempty"`
}

TorznabIndexerCooldown captures a persisted rate-limit suspension window for an indexer.

type TorznabIndexerError added in v1.8.0

type TorznabIndexerError struct {
	ID           int        `json:"id"`
	IndexerID    int        `json:"indexer_id"`
	ErrorMessage string     `json:"error_message"`
	ErrorCode    string     `json:"error_code"`
	OccurredAt   time.Time  `json:"occurred_at"`
	ResolvedAt   *time.Time `json:"resolved_at,omitempty"`
	ErrorCount   int        `json:"error_count"`
}

TorznabIndexerError represents an error that occurred with an indexer

type TorznabIndexerHealth added in v1.8.0

type TorznabIndexerHealth struct {
	IndexerID        int        `json:"indexer_id"`
	IndexerName      string     `json:"indexer_name"`
	Enabled          bool       `json:"enabled"`
	LastTestStatus   string     `json:"last_test_status"`
	ErrorsLast24h    int        `json:"errors_last_24h"`
	UnresolvedErrors int        `json:"unresolved_errors"`
	AvgLatencyMs     *float64   `json:"avg_latency_ms,omitempty"`
	SuccessRatePct   *float64   `json:"success_rate_pct,omitempty"`
	RequestsLast7d   *int       `json:"requests_last_7d,omitempty"`
	LastMeasuredAt   *time.Time `json:"last_measured_at,omitempty"`
}

TorznabIndexerHealth represents the health status of an indexer

type TorznabIndexerLatency added in v1.8.0

type TorznabIndexerLatency struct {
	ID            int       `json:"id"`
	IndexerID     int       `json:"indexer_id"`
	OperationType string    `json:"operation_type"`
	LatencyMs     int       `json:"latency_ms"`
	Success       bool      `json:"success"`
	MeasuredAt    time.Time `json:"measured_at"`
}

TorznabIndexerLatency represents a latency measurement

type TorznabIndexerLatencyStats added in v1.8.0

type TorznabIndexerLatencyStats struct {
	IndexerID          int       `json:"indexer_id"`
	OperationType      string    `json:"operation_type"`
	TotalRequests      int       `json:"total_requests"`
	SuccessfulRequests int       `json:"successful_requests"`
	AvgLatencyMs       *float64  `json:"avg_latency_ms,omitempty"`
	MinLatencyMs       *int      `json:"min_latency_ms,omitempty"`
	MaxLatencyMs       *int      `json:"max_latency_ms,omitempty"`
	SuccessRatePct     float64   `json:"success_rate_pct"`
	LastMeasuredAt     time.Time `json:"last_measured_at"`
}

TorznabIndexerLatencyStats represents aggregated latency statistics

type TorznabIndexerStore added in v1.8.0

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

TorznabIndexerStore manages Torznab indexers in the database

func NewTorznabIndexerStore added in v1.8.0

func NewTorznabIndexerStore(db dbinterface.Querier, encryptionKey []byte) (*TorznabIndexerStore, error)

NewTorznabIndexerStore creates a new TorznabIndexerStore

func (*TorznabIndexerStore) CleanupOldLatency added in v1.8.0

func (s *TorznabIndexerStore) CleanupOldLatency(ctx context.Context, olderThan time.Duration) (int64, error)

CleanupOldLatency removes latency records older than the specified duration

func (*TorznabIndexerStore) Create added in v1.8.0

func (s *TorznabIndexerStore) Create(ctx context.Context, name, baseURL, apiKey string, enabled bool, priority, timeoutSeconds int) (*TorznabIndexer, error)

Create creates a new Torznab indexer

func (*TorznabIndexerStore) CreateWithIndexerID added in v1.8.0

func (s *TorznabIndexerStore) CreateWithIndexerID(ctx context.Context, name, baseURL, indexerID, apiKey string, enabled bool, priority, timeoutSeconds int, backend TorznabBackend) (*TorznabIndexer, error)

func (*TorznabIndexerStore) Delete added in v1.8.0

func (s *TorznabIndexerStore) Delete(ctx context.Context, id int) error

Delete deletes a Torznab indexer String pool cleanup is handled by the centralized CleanupUnusedStrings() function

func (*TorznabIndexerStore) DeleteRateLimitCooldown added in v1.8.0

func (s *TorznabIndexerStore) DeleteRateLimitCooldown(ctx context.Context, indexerID int) error

DeleteRateLimitCooldown removes any persisted cooldown for the provided indexer ID.

func (*TorznabIndexerStore) Get added in v1.8.0

Get retrieves a Torznab indexer by ID using the view

func (*TorznabIndexerStore) GetAllHealth added in v1.8.0

func (s *TorznabIndexerStore) GetAllHealth(ctx context.Context) ([]TorznabIndexerHealth, error)

GetAllHealth retrieves health information for all indexers

func (*TorznabIndexerStore) GetCapabilities added in v1.8.0

func (s *TorznabIndexerStore) GetCapabilities(ctx context.Context, indexerID int) ([]string, error)

GetCapabilities retrieves all capabilities for an indexer

func (*TorznabIndexerStore) GetCategories added in v1.8.0

func (s *TorznabIndexerStore) GetCategories(ctx context.Context, indexerID int) ([]TorznabIndexerCategory, error)

GetCategories retrieves all categories for an indexer

func (*TorznabIndexerStore) GetDecryptedAPIKey added in v1.8.0

func (s *TorznabIndexerStore) GetDecryptedAPIKey(indexer *TorznabIndexer) (string, error)

GetDecryptedAPIKey returns the decrypted API key for an indexer

func (*TorznabIndexerStore) GetHealth added in v1.8.0

func (s *TorznabIndexerStore) GetHealth(ctx context.Context, indexerID int) (*TorznabIndexerHealth, error)

GetHealth retrieves health information for an indexer

func (*TorznabIndexerStore) GetLatencyStats added in v1.8.0

func (s *TorznabIndexerStore) GetLatencyStats(ctx context.Context, indexerID int) ([]TorznabIndexerLatencyStats, error)

GetLatencyStats retrieves aggregated latency statistics for an indexer

func (*TorznabIndexerStore) GetRecentErrors added in v1.8.0

func (s *TorznabIndexerStore) GetRecentErrors(ctx context.Context, indexerID int, limit int) ([]TorznabIndexerError, error)

GetRecentErrors retrieves recent errors for an indexer

func (*TorznabIndexerStore) List added in v1.8.0

List retrieves all Torznab indexers using the view, ordered by priority (descending) and name

func (*TorznabIndexerStore) ListEnabled added in v1.8.0

func (s *TorznabIndexerStore) ListEnabled(ctx context.Context) ([]*TorznabIndexer, error)

ListEnabled retrieves all enabled Torznab indexers using the view, ordered by priority

func (*TorznabIndexerStore) ListRateLimitCooldowns added in v1.8.0

func (s *TorznabIndexerStore) ListRateLimitCooldowns(ctx context.Context) ([]TorznabIndexerCooldown, error)

ListRateLimitCooldowns returns any persisted cooldown windows for Torznab indexers.

func (*TorznabIndexerStore) RecordError added in v1.8.0

func (s *TorznabIndexerStore) RecordError(ctx context.Context, indexerID int, errorMessage, errorCode string) error

RecordError records an error for an indexer

func (*TorznabIndexerStore) RecordLatency added in v1.8.0

func (s *TorznabIndexerStore) RecordLatency(ctx context.Context, indexerID int, operationType string, latencyMs int, success bool) error

RecordLatency records a latency measurement for an indexer

func (*TorznabIndexerStore) ResolveErrors added in v1.8.0

func (s *TorznabIndexerStore) ResolveErrors(ctx context.Context, indexerID int) error

ResolveErrors marks all unresolved errors for an indexer as resolved

func (*TorznabIndexerStore) SetCapabilities added in v1.8.0

func (s *TorznabIndexerStore) SetCapabilities(ctx context.Context, indexerID int, capabilities []string) error

SetCapabilities replaces all capabilities for an indexer

func (*TorznabIndexerStore) SetCategories added in v1.8.0

func (s *TorznabIndexerStore) SetCategories(ctx context.Context, indexerID int, categories []TorznabIndexerCategory) error

SetCategories replaces all categories for an indexer

func (*TorznabIndexerStore) Test added in v1.8.0

func (s *TorznabIndexerStore) Test(ctx context.Context, baseURL, apiKey string) error

Test tests the connection to a Torznab indexer by querying its capabilities

func (*TorznabIndexerStore) Update added in v1.8.0

Update updates a Torznab indexer

func (*TorznabIndexerStore) UpdateTestStatus added in v1.8.0

func (s *TorznabIndexerStore) UpdateTestStatus(ctx context.Context, id int, status string, errorMsg *string) error

UpdateTestStatus updates the test status of an indexer

func (*TorznabIndexerStore) UpsertRateLimitCooldown added in v1.8.0

func (s *TorznabIndexerStore) UpsertRateLimitCooldown(ctx context.Context, indexerID int, resumeAt time.Time, cooldown time.Duration, reason string) error

UpsertRateLimitCooldown stores or updates the cooldown window for an indexer.

type TorznabIndexerUpdateParams added in v1.8.0

type TorznabIndexerUpdateParams struct {
	Name           string
	BaseURL        string
	IndexerID      *string
	Backend        *TorznabBackend
	APIKey         string
	Enabled        *bool
	Priority       *int
	TimeoutSeconds *int
}

TorznabIndexerUpdateParams captures optional fields for updating an indexer.

type TorznabRecentSearch added in v1.8.0

type TorznabRecentSearch struct {
	CacheKey     string     `json:"cacheKey"`
	Scope        string     `json:"scope"`
	Query        string     `json:"query"`
	Categories   []int      `json:"categories"`
	IndexerIDs   []int      `json:"indexerIds"`
	TotalResults int        `json:"totalResults"`
	CachedAt     time.Time  `json:"cachedAt"`
	LastUsedAt   *time.Time `json:"lastUsedAt,omitempty"`
	ExpiresAt    time.Time  `json:"expiresAt"`
	HitCount     int64      `json:"hitCount"`
}

TorznabRecentSearch captures metadata about a cached search request for UI consumption.

type TorznabSearchCacheEntry added in v1.8.0

type TorznabSearchCacheEntry struct {
	ID                 int64
	CacheKey           string
	Scope              string
	Query              string
	Categories         []int
	IndexerIDs         []int
	RequestFingerprint string
	ResponseData       []byte
	TotalResults       int
	CachedAt           time.Time
	LastUsedAt         time.Time
	ExpiresAt          time.Time
	HitCount           int64
}

TorznabSearchCacheEntry captures a cached Torznab search response.

type TorznabSearchCacheSettings added in v1.8.0

type TorznabSearchCacheSettings struct {
	TTLMinutes int
	UpdatedAt  *time.Time
}

TorznabSearchCacheSettings tracks persisted cache configuration.

type TorznabSearchCacheStats added in v1.8.0

type TorznabSearchCacheStats struct {
	Entries         int64      `json:"entries"`
	TotalHits       int64      `json:"totalHits"`
	ApproxSizeBytes int64      `json:"approxSizeBytes"`
	OldestCachedAt  *time.Time `json:"oldestCachedAt,omitempty"`
	NewestCachedAt  *time.Time `json:"newestCachedAt,omitempty"`
	LastUsedAt      *time.Time `json:"lastUsedAt,omitempty"`
	Enabled         bool       `json:"enabled"`
	TTLMinutes      int        `json:"ttlMinutes"`
}

TorznabSearchCacheStats provides aggregated cache metrics for observability.

type TorznabSearchCacheStore added in v1.8.0

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

TorznabSearchCacheStore persists search cache entries.

func NewTorznabSearchCacheStore added in v1.8.0

func NewTorznabSearchCacheStore(db dbinterface.Querier) *TorznabSearchCacheStore

NewTorznabSearchCacheStore constructs a new search cache store.

func (*TorznabSearchCacheStore) CleanupExpired added in v1.8.0

func (s *TorznabSearchCacheStore) CleanupExpired(ctx context.Context) (int64, error)

CleanupExpired removes all expired cache rows.

func (*TorznabSearchCacheStore) Fetch added in v1.8.0

Fetch returns a cached search response by cache key.

func (*TorznabSearchCacheStore) FindActiveByScopeAndQuery added in v1.8.0

func (s *TorznabSearchCacheStore) FindActiveByScopeAndQuery(ctx context.Context, scope string, query string) ([]*TorznabSearchCacheEntry, error)

FindActiveByScopeAndQuery returns matching, non-expired cache entries for a scope/query pair.

func (*TorznabSearchCacheStore) Flush added in v1.8.0

Flush removes every cache entry.

func (*TorznabSearchCacheStore) GetSettings added in v1.8.0

GetSettings returns the current cache settings (if any).

func (*TorznabSearchCacheStore) InvalidateByIndexerIDs added in v1.8.0

func (s *TorznabSearchCacheStore) InvalidateByIndexerIDs(ctx context.Context, indexerIDs []int) (int64, error)

InvalidateByIndexerIDs removes cache entries referencing any of the provided indexers.

func (*TorznabSearchCacheStore) RebaseTTL added in v1.8.0

func (s *TorznabSearchCacheStore) RebaseTTL(ctx context.Context, ttlMinutes int) (int64, error)

RebaseTTL recalculates expires_at for all cached entries using the provided TTL minutes.

func (*TorznabSearchCacheStore) RecentSearches added in v1.8.0

func (s *TorznabSearchCacheStore) RecentSearches(ctx context.Context, scope string, limit int) ([]*TorznabRecentSearch, error)

RecentSearches returns the most recently used cached search queries.

func (*TorznabSearchCacheStore) Stats added in v1.8.0

Stats returns summary metrics for the search cache table.

func (*TorznabSearchCacheStore) Store added in v1.8.0

Store inserts or updates a cached search response.

func (*TorznabSearchCacheStore) Touch added in v1.8.0

func (s *TorznabSearchCacheStore) Touch(ctx context.Context, id int64)

Touch updates last_used_at and hit_count for a cache entry.

func (*TorznabSearchCacheStore) UpdateSettings added in v1.8.0

func (s *TorznabSearchCacheStore) UpdateSettings(ctx context.Context, ttlMinutes int) (*TorznabSearchCacheSettings, error)

UpdateSettings persists TTL minutes and returns the updated settings.

type TorznabTorrentCacheEntry added in v1.8.0

type TorznabTorrentCacheEntry struct {
	IndexerID   int
	CacheKey    string
	GUID        string
	DownloadURL string
	InfoHash    string
	Title       string
	SizeBytes   int64
	TorrentData []byte
}

TorznabTorrentCacheEntry represents a cached torrent payload downloaded from an indexer.

type TorznabTorrentCacheStore added in v1.8.0

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

TorznabTorrentCacheStore manages cached Torznab torrent files.

func NewTorznabTorrentCacheStore added in v1.8.0

func NewTorznabTorrentCacheStore(db dbinterface.Querier) *TorznabTorrentCacheStore

NewTorznabTorrentCacheStore constructs a new cache store.

func (*TorznabTorrentCacheStore) Cleanup added in v1.8.0

func (s *TorznabTorrentCacheStore) Cleanup(ctx context.Context, olderThan time.Duration) (int64, error)

Cleanup removes entries older than the provided age, returning the number of deleted rows.

func (*TorznabTorrentCacheStore) Fetch added in v1.8.0

func (s *TorznabTorrentCacheStore) Fetch(ctx context.Context, indexerID int, cacheKey string, maxAge time.Duration) ([]byte, bool, error)

Fetch returns cached torrent data when available and not expired. maxAge <= 0 disables expiration checks.

func (*TorznabTorrentCacheStore) Store added in v1.8.0

Store inserts or updates a cached torrent payload.

type TrackerCustomization added in v1.9.0

type TrackerCustomization struct {
	ID              int       `json:"id"`
	DisplayName     string    `json:"displayName"`
	Domains         []string  `json:"domains"`
	IncludedInStats []string  `json:"includedInStats,omitempty"`
	CreatedAt       time.Time `json:"createdAt"`
	UpdatedAt       time.Time `json:"updatedAt"`
}

type TrackerCustomizationStore added in v1.9.0

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

func NewTrackerCustomizationStore added in v1.9.0

func NewTrackerCustomizationStore(db dbinterface.Querier) *TrackerCustomizationStore

func (*TrackerCustomizationStore) Create added in v1.9.0

func (*TrackerCustomizationStore) Delete added in v1.9.0

func (s *TrackerCustomizationStore) Delete(ctx context.Context, id int) error

func (*TrackerCustomizationStore) Get added in v1.9.0

func (*TrackerCustomizationStore) List added in v1.9.0

func (*TrackerCustomizationStore) Update added in v1.9.0

type TrackerRule added in v1.8.0

type TrackerRule struct {
	ID                      int       `json:"id"`
	InstanceID              int       `json:"instanceId"`
	Name                    string    `json:"name"`
	TrackerPattern          string    `json:"trackerPattern"`
	TrackerDomains          []string  `json:"trackerDomains,omitempty"`
	Category                *string   `json:"category,omitempty"`
	Tag                     *string   `json:"tag,omitempty"`
	UploadLimitKiB          *int64    `json:"uploadLimitKiB,omitempty"`
	DownloadLimitKiB        *int64    `json:"downloadLimitKiB,omitempty"`
	RatioLimit              *float64  `json:"ratioLimit,omitempty"`
	SeedingTimeLimitMinutes *int64    `json:"seedingTimeLimitMinutes,omitempty"`
	Enabled                 bool      `json:"enabled"`
	SortOrder               int       `json:"sortOrder"`
	CreatedAt               time.Time `json:"createdAt"`
	UpdatedAt               time.Time `json:"updatedAt"`
}

type TrackerRuleStore added in v1.8.0

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

func NewTrackerRuleStore added in v1.8.0

func NewTrackerRuleStore(db dbinterface.Querier) *TrackerRuleStore

func (*TrackerRuleStore) Create added in v1.8.0

func (s *TrackerRuleStore) Create(ctx context.Context, rule *TrackerRule) (*TrackerRule, error)

func (*TrackerRuleStore) Delete added in v1.8.0

func (s *TrackerRuleStore) Delete(ctx context.Context, instanceID int, id int) error

func (*TrackerRuleStore) Get added in v1.8.0

func (s *TrackerRuleStore) Get(ctx context.Context, id int) (*TrackerRule, error)

func (*TrackerRuleStore) ListByInstance added in v1.8.0

func (s *TrackerRuleStore) ListByInstance(ctx context.Context, instanceID int) ([]*TrackerRule, error)

func (*TrackerRuleStore) Reorder added in v1.8.0

func (s *TrackerRuleStore) Reorder(ctx context.Context, instanceID int, orderedIDs []int) error

func (*TrackerRuleStore) Update added in v1.8.0

func (s *TrackerRuleStore) Update(ctx context.Context, rule *TrackerRule) (*TrackerRule, error)

type User

type User struct {
	ID           int    `json:"id"`
	Username     string `json:"username"`
	PasswordHash string `json:"-"`
}

type UserStore

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

func NewUserStore

func NewUserStore(db dbinterface.Querier) *UserStore

func (*UserStore) Create

func (s *UserStore) Create(ctx context.Context, username, passwordHash string) (*User, error)

func (*UserStore) Exists

func (s *UserStore) Exists(ctx context.Context) (bool, error)

func (*UserStore) Get

func (s *UserStore) Get(ctx context.Context) (*User, error)

func (*UserStore) GetByUsername

func (s *UserStore) GetByUsername(ctx context.Context, username string) (*User, error)

func (*UserStore) UpdatePassword

func (s *UserStore) UpdatePassword(ctx context.Context, passwordHash string) error

Jump to

Keyboard shortcuts

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