Documentation
¶
Overview ¶
Package autosearch implements on-demand automatic search: given a movie, search all indexers, pick the best release that satisfies the quality profile, and submit it to a download client. Used by both the single-movie search button and the bulk "Search All" action on the Wanted page.
Index ¶
Constants ¶
const ( StatusGrabbed = "grabbed" StatusNoMatch = "no_match" StatusSkipped = "skipped" )
Result status constants.
const MaxBulkMovies = 100
MaxBulkMovies is the maximum number of movie IDs accepted in a single bulk search request.
Variables ¶
This section is empty.
Functions ¶
func Explain ¶
func Explain(reason SkipReason, ctx ExplainContext) string
Explain generates a human-readable explanation for a skip or grab decision.
Types ¶
type BulkResult ¶
type BulkResult struct {
Searched int `json:"searched"`
Grabbed int `json:"grabbed"`
Results []*Result `json:"results"`
}
BulkResult summarises a bulk auto-search operation.
type ExplainContext ¶
type ExplainContext struct {
ProfileName string
MinCFScore int
CurrentFile string // e.g. "1080p BluRay"
CFScore int
MatchedFormats []string
QualityName string // e.g. "720p WEB-DL"
QualityScore int
TotalScore int
}
ExplainContext provides the details needed to generate human-readable explanations.
type ExplainResult ¶
type ExplainResult struct {
MovieID string `json:"movie_id"`
ProfileName string `json:"profile_name"`
CurrentFile *plugin.Quality `json:"current_file,omitempty"`
Decisions []ReleaseDecision `json:"decisions"`
}
ExplainResult holds the dry-run decisions for all candidate releases.
type GrabInfo ¶
type GrabInfo struct {
ID string `json:"id"`
MovieID string `json:"movie_id"`
ReleaseTitle string `json:"release_title"`
Protocol string `json:"protocol"`
Size int64 `json:"size"`
GrabbedAt string `json:"grabbed_at"`
Breakdown json.RawMessage `json:"score_breakdown,omitempty"`
}
GrabInfo is the subset of grab history returned to the caller.
type ReleaseDecision ¶
type ReleaseDecision struct {
Title string `json:"title"`
GUID string `json:"guid"`
Outcome string `json:"outcome"` // "grabbed", "skipped"
Reason SkipReason `json:"reason"`
Explanation string `json:"explanation"`
QualityScore int `json:"quality_score"`
CFScore int `json:"cf_score"`
MatchedFormats []string `json:"matched_formats,omitempty"`
Breakdown *plugin.ScoreBreakdown `json:"breakdown,omitempty"`
}
ReleaseDecision records the outcome for one candidate release during search.
type Result ¶
type Result struct {
MovieID string `json:"movie_id"`
Status string `json:"result"` // "grabbed", "no_match", "skipped"
Reason string `json:"reason,omitempty"`
Grab *GrabInfo `json:"grab,omitempty"`
}
Result describes the outcome of an auto-search for a single movie.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service orchestrates automatic search and grab for movies.
func NewService ¶
func NewService( indexerSvc *indexer.Service, movieSvc *movie.Service, downloaderSvc *downloader.Service, blocklistSvc *blocklist.Service, qualitySvc *quality.Service, cfSvc *customformat.Service, tagSvc *tag.Service, bus *events.Bus, logger *slog.Logger, ) *Service
NewService creates a new auto-search Service.
func (*Service) SearchMovie ¶
SearchMovie performs a full indexer search for a single movie, picks the best release satisfying the quality profile, and submits it to a download client. Works on both monitored and unmonitored movies (explicit user action).
func (*Service) SearchMovieExplain ¶
SearchMovieExplain performs the same search and evaluation as SearchMovie but does NOT grab anything. It returns a decision for every candidate, explaining why each was accepted or rejected.
func (*Service) SearchMovies ¶
func (s *Service) SearchMovies(ctx context.Context, movieIDs []string) *BulkResult
SearchMovies runs SearchMovie for each movie ID with bounded concurrency. Progress events are published to the event bus for WebSocket delivery.
type SkipReason ¶
type SkipReason string
SkipReason identifies why a release candidate was not grabbed.
const ( ReasonGrabbed SkipReason = "grabbed" ReasonBlocklisted SkipReason = "blocklisted" ReasonCFScoreBelowMinimum SkipReason = "cf_score_below_minimum" ReasonQualityNotAllowed SkipReason = "quality_not_in_profile" ReasonNoUpgradeNeeded SkipReason = "no_upgrade_needed" ReasonUpgradeDisabled SkipReason = "upgrade_disabled" ReasonEditionNotPreferred SkipReason = "edition_not_preferred" ReasonDownloadClientReject SkipReason = "download_client_rejected" ReasonAlreadyDownloading SkipReason = "already_downloading" )