{"modulePath":"github.com/beacon-stack/prism","version":"v0.13.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package plugin\n\nPackage plugin defines the public interfaces and value types for Prism's plugin system. Indexer, DownloadClient, and Notifier implementations (built-in or external) depend only on this package.\n\n## Variables\n\n```go\nvar ErrItemNotFound = errors.New(\"download client: item not found\")\n```\nErrItemNotFound is returned by DownloadClient implementations when the item asked about no longer exists in the client (e.g. the user removed it directly in the client's UI, or the client forgot it after a restart).\n\nCallers that persist grab history (queue sync, stall watchers) should distinguish this from transient errors: on ErrItemNotFound the grab is definitively gone and should be marked removed, whereas on any other error the correct behaviour is to log and retry on the next poll — a brief network blip must not nuke the queue.\n\n## Types\n\n```go\ntype AudioChannels string\n```\nAudioChannels is the channel layout of a release.\n\n```go\nconst (\n\tAudioChannelsUnknown AudioChannels = \"\"\n\tAudioChannels71      AudioChannels = \"7.1\"\n\tAudioChannels51      AudioChannels = \"5.1\"\n\tAudioChannels20      AudioChannels = \"2.0\"\n\tAudioChannels10      AudioChannels = \"1.0\"\n)\n```\n\n```go\ntype AudioCodec string\n```\nAudioCodec is the audio codec of a release.\n\n```go\nconst (\n\tAudioCodecUnknown     AudioCodec = \"\"\n\tAudioCodecTrueHD      AudioCodec = \"truehd\"\n\tAudioCodecTrueHDAtmos AudioCodec = \"truehd_atmos\"\n\tAudioCodecDTSX        AudioCodec = \"dts_x\"\n\tAudioCodecDTSHDMA     AudioCodec = \"dts_hd_ma\"\n\tAudioCodecDTSHD       AudioCodec = \"dts_hd\"\n\tAudioCodecDTS         AudioCodec = \"dts\"\n\tAudioCodecEAC3Atmos   AudioCodec = \"eac3_atmos\"\n\tAudioCodecEAC3        AudioCodec = \"eac3\"\n\tAudioCodecAC3         AudioCodec = \"ac3\"\n\tAudioCodecAAC         AudioCodec = \"aac\"\n\tAudioCodecFLAC        AudioCodec = \"flac\"\n\tAudioCodecPCM         AudioCodec = \"pcm\"\n\tAudioCodecMP3         AudioCodec = \"mp3\"\n\tAudioCodecOpus        AudioCodec = \"opus\"\n)\n```\n\n```go\ntype Capabilities struct {\n\tSearchAvailable   bool\n\tTVSearchAvailable bool // future-proofing; unused in v1\n\tMovieSearch       bool\n\tCategories        []int // Newznab/Torznab category IDs\n}\n```\nCapabilities describes what an indexer supports.\n\n```go\ntype Codec string\n```\nCodec is the video codec of a release.\n\n```go\nconst (\n\tCodecUnknown Codec = \"unknown\"\n\tCodecX264    Codec = \"x264\"\n\tCodecX265    Codec = \"x265\"\n\tCodecAV1     Codec = \"av1\"\n\tCodecXVID    Codec = \"xvid\"\n)\n```\n\n```go\ntype DownloadClient interface {\n\tName() string\n\tProtocol() Protocol\n\n\t// Add submits a release to the download client.\n\t// Returns the client-assigned item ID for future status queries.\n\tAdd(ctx context.Context, r Release) (clientItemID string, err error)\n\n\t// Status returns the current state of a download client item.\n\tStatus(ctx context.Context, clientItemID string) (QueueItem, error)\n\n\t// GetQueue returns all items currently in the download client.\n\tGetQueue(ctx context.Context) ([]QueueItem, error)\n\n\t// Remove deletes an item from the download client.\n\t// If deleteFiles is true, the downloaded data is also deleted.\n\tRemove(ctx context.Context, clientItemID string, deleteFiles bool) error\n\n\t// Test validates that the connection to the download client works.\n\tTest(ctx context.Context) error\n}\n```\nDownloadClient is the plugin interface for download clients.\n\n```go\ntype DownloadStatus string\n```\nDownloadStatus is the state of an item in the download client.\n\n```go\nconst (\n\tStatusQueued      DownloadStatus = \"queued\"\n\tStatusDownloading DownloadStatus = \"downloading\"\n\tStatusCompleted   DownloadStatus = \"completed\"\n\tStatusPaused      DownloadStatus = \"paused\"\n\tStatusFailed      DownloadStatus = \"failed\"\n)\n```\n\n```go\ntype EventType string\n```\nEventType identifies what happened.\n\n```go\nconst (\n\tEventMovieAdded   EventType = \"movie_added\"\n\tEventMovieDeleted EventType = \"movie_deleted\"\n\tEventGrabStarted  EventType = \"grab_started\"\n\tEventDownloadDone EventType = \"download_done\"\n\tEventImportDone   EventType = \"import_done\"\n\tEventImportFailed EventType = \"import_failed\"\n\tEventHealthIssue  EventType = \"health_issue\"\n\tEventHealthOK     EventType = \"health_ok\"\n)\n```\n\n```go\ntype HDRFormat string\n```\nHDRFormat is the high dynamic range format of a release.\n\n```go\nconst (\n\tHDRNone        HDRFormat = \"none\"\n\tHDRUnknown     HDRFormat = \"unknown\"\n\tHDRHDR10       HDRFormat = \"hdr10\"\n\tHDRDolbyVision HDRFormat = \"dolby_vision\"\n\tHDRHLG         HDRFormat = \"hlg\"\n\tHDRHDR10Plus   HDRFormat = \"hdr10plus\"\n)\n```\n\n```go\ntype ImportList interface {\n\tName() string\n\tFetch(ctx context.Context) ([]ImportListItem, error)\n\tTest(ctx context.Context) error\n}\n```\nImportList is the plugin interface for import list sources. Implementations fetch movies from external services (TMDb, Trakt, Plex, etc.) and return them as a flat list. The sync service handles deduplication, exclusion checks, and adding movies to the library.\n\n```go\ntype ImportListItem struct {\n\tTMDbID     int    // required — canonical identifier\n\tIMDbID     string // optional; used for display/logging\n\tTitle      string\n\tYear       int\n\tPosterPath string // optional; TMDb poster path (e.g. \"/abc123.jpg\")\n}\n```\nImportListItem is a single movie returned by an import list source.\n\n```go\ntype Indexer interface {\n\t// Name returns the human-readable plugin name, e.g. \"Torznab\".\n\tName() string\n\n\t// Protocol returns the release download mechanism this indexer provides.\n\tProtocol() Protocol\n\n\t// Capabilities returns what search types this indexer supports.\n\tCapabilities(ctx context.Context) (Capabilities, error)\n\n\t// Search queries the indexer for releases matching the query.\n\tSearch(ctx context.Context, q SearchQuery) ([]Release, error)\n\n\t// GetRecent returns the most recent releases from the indexer's RSS feed.\n\tGetRecent(ctx context.Context) ([]Release, error)\n\n\t// Test validates that the indexer is reachable and configured correctly.\n\tTest(ctx context.Context) error\n}\n```\nIndexer is the plugin interface for release indexers.\n\n```go\ntype IndexerFlag string\n```\nIndexerFlag represents a flag reported by an indexer for a release.\n\n```go\nconst (\n\tFlagFreeleech    IndexerFlag = \"freeleech\"\n\tFlagHalfleech    IndexerFlag = \"halfleech\"\n\tFlagFreeleech75  IndexerFlag = \"freeleech_75\"\n\tFlagFreeleech25  IndexerFlag = \"freeleech_25\"\n\tFlagDoubleUpload IndexerFlag = \"double_upload\"\n\tFlagInternal     IndexerFlag = \"internal\"\n\tFlagScene        IndexerFlag = \"scene\"\n\tFlagNuked        IndexerFlag = \"nuked\"\n)\n```\n\n```go\ntype MediaServer interface {\n\t// Name returns the human-readable name of the media server plugin.\n\tName() string\n\n\t// RefreshLibrary tells the media server to re-scan the library section\n\t// that contains moviePath. Implementations may fall back to a full\n\t// library refresh if path-scoped scanning is unavailable.\n\tRefreshLibrary(ctx context.Context, moviePath string) error\n\n\t// Test verifies that the media server is reachable and the credentials\n\t// are valid.\n\tTest(ctx context.Context) error\n}\n```\nMediaServer is implemented by media server plugins (Plex, Emby, Jellyfin). After a movie file is imported, the dispatcher calls RefreshLibrary so the media server picks up the new file without waiting for a scheduled scan.\n\n```go\ntype NotificationEvent struct {\n\tType      EventType\n\tTimestamp time.Time\n\tMovieID   string         // UUID, if movie-related; empty otherwise\n\tMessage   string         // human-readable summary\n\tData      map[string]any // event-specific extra fields\n}\n```\nNotificationEvent carries the context of something that happened.\n\n```go\ntype Notifier interface {\n\tName() string\n\tNotify(ctx context.Context, event NotificationEvent) error\n\tTest(ctx context.Context) error\n}\n```\nNotifier is the plugin interface for notification channels.\n\n```go\ntype Protocol string\n```\nProtocol identifies the release download mechanism.\n\n```go\nconst (\n\tProtocolTorrent Protocol = \"torrent\"\n\tProtocolNZB     Protocol = \"nzb\"\n\tProtocolUnknown Protocol = \"unknown\"\n)\n```\n\n```go\ntype Quality struct {\n\tResolution    Resolution    `json:\"resolution\"`\n\tSource        Source        `json:\"source\"`\n\tCodec         Codec         `json:\"codec\"`\n\tHDR           HDRFormat     `json:\"hdr\"`\n\tAudioCodec    AudioCodec    `json:\"audio_codec,omitempty\"`\n\tAudioChannels AudioChannels `json:\"audio_channels,omitempty\"`\n\t// Name is the human-readable label derived from the video fields,\n\t// e.g. \"Bluray-1080p x265\" or \"WEBDL-2160p HDR10\".\n\tName string `json:\"name\"`\n}\n```\nQuality describes the technical characteristics of a release. It is a value type — embedded in releases, files, and profiles.\n\n```go\nfunc (q Quality) AtLeast(other Quality) bool\n```\nAtLeast reports whether q meets or exceeds other.\n\n```go\nfunc (q Quality) BetterThan(other Quality) bool\n```\nBetterThan reports whether q is strictly better than other.\n\n```go\nfunc (q Quality) Score() int\n```\nScore returns a numeric rank for this quality used when comparing two qualities. Higher is better.\n\n```go\ntype QueueItem struct {\n\tClientItemID string\n\tTitle        string\n\tStatus       DownloadStatus\n\tSize         int64\n\tDownloaded   int64\n\tSeedRatio    float64 // torrent only; 0 for NZB\n\tError        string\n\t// ContentPath is the absolute filesystem path to the downloaded content.\n\t// For single-file downloads this is the file path; for multi-file downloads\n\t// it is the root directory. Empty until the download client reports it.\n\tContentPath string\n\t// AddedAt is the Unix timestamp when the item was added to the client.\n\t// Zero if the client does not report this field.\n\tAddedAt int64\n}\n```\nQueueItem represents an item tracked in the download client.\n\n```go\ntype Release struct {\n\tGUID         string\n\tTitle        string\n\tIndexer      string\n\tProtocol     Protocol\n\tDownloadURL  string\n\tInfoURL      string\n\tSize         int64\n\tSeeds        int\n\tPeers        int\n\tAgeDays      float64\n\tQuality      Quality\n\tEdition      string // canonical edition name parsed from title; empty = untagged\n\tReleaseGroup string // scene group name parsed from title; empty = unknown\n\tIndexerFlags []IndexerFlag\n\t// InfoHash is the v1 BitTorrent info hash, lowercased 40-char hex.\n\t// Populated when the indexer exposes it (torznab `infohash` attr, or\n\t// extractable from a magnet DownloadURL). Empty when the URL is an\n\t// HTTP redirect through a proxy and the indexer doesn't expose the\n\t// hash separately. Used to dedupe cross-indexer copies of the same\n\t// torrent in Prism's search dialog — see indexer.dedupeByInfoHash.\n\tInfoHash string\n\n\t// Media context — populated by the API layer before sending to the\n\t// download client. Haul uses these to (1) rename files on\n\t// completion and (2) answer history-lookup queries later\n\t// (\"have I downloaded anything for movie_id=X?\"). All optional;\n\t// leaving empty disables the lookup integration for this grab.\n\tMediaTitle string `json:\"media_title,omitempty\"`\n\tMediaYear  int    `json:\"media_year,omitempty\"`\n\tTMDBID     int    `json:\"tmdb_id,omitempty\"`\n\tMovieID    string `json:\"movie_id,omitempty\"` // Prism movie UUID\n}\n```\nRelease is the transient result of an indexer search. It is not stored in the database. A summary is written to GrabHistory when a release is grabbed.\n\n```go\ntype Resolution string\n```\nResolution is the video resolution of a release.\n\n```go\nconst (\n\tResolutionUnknown Resolution = \"unknown\"\n\tResolutionSD      Resolution = \"sd\" // implied SD (e.g. DVDRip without explicit resolution)\n\tResolution480p    Resolution = \"480p\"\n\tResolution576p    Resolution = \"576p\"\n\tResolution720p    Resolution = \"720p\"\n\tResolution1080p   Resolution = \"1080p\"\n\tResolution2160p   Resolution = \"2160p\" // 4K\n)\n```\n\n```go\ntype ScoreBreakdown struct {\n\tTotal      int              `json:\"total\"`\n\tDimensions []ScoreDimension `json:\"dimensions\"`\n\t// CustomFormatScore is the sum of matched custom format scores for the\n\t// quality profile. It sits alongside (not inside) Total because CF scoring\n\t// is an independent dimension used for separate thresholds.\n\tCustomFormatScore int      `json:\"custom_format_score\"`\n\tMatchedFormats    []string `json:\"matched_formats,omitempty\"`\n\t// EditionBonus is the bonus points awarded when the release edition\n\t// matches the movie's preferred edition (+30 pts). It is additive\n\t// to Total and reflected in the Dimensions list.\n\tEditionBonus int `json:\"edition_bonus\"`\n}\n```\nScoreBreakdown records how a release was evaluated against a quality profile. Each dimension is independently scored; Total is the sum.\n\n```go\ntype ScoreDimension struct {\n\tName    string `json:\"name\"`    // \"resolution\", \"source\", \"codec\", \"hdr\"\n\tScore   int    `json:\"score\"`   // points awarded for this dimension\n\tMax     int    `json:\"max\"`     // maximum possible for this dimension\n\tMatched bool   `json:\"matched\"` // did it meet the profile requirement?\n\tGot     string `json:\"got\"`     // what we found (e.g. \"x264\")\n\tWant    string `json:\"want\"`    // what the profile requires (e.g. \"x265\")\n}\n```\nScoreDimension is one component of a ScoreBreakdown.\n\n```go\ntype SearchQuery struct {\n\tQuery  string // free-text or scene title\n\tTMDBID int    // preferred when available\n\tIMDBID string // e.g. \"tt0137523\"\n\tYear   int\n}\n```\nSearchQuery is the input to an indexer search.\n\n```go\ntype SeedLimiter interface {\n\tSetSeedLimits(ctx context.Context, clientItemID string, ratioLimit float64, seedTimeSecs int) error\n}\n```\nSeedLimiter is an optional interface for download clients that support configuring per-torrent seed ratio and seed time limits. Implementations should treat ratioLimit \\\u003c= 0 as \"use client default\" and seedTimeSecs \\\u003c= 0 as \"no time limit\".\n\n```go\ntype Source string\n```\nSource is the origin/format of a release.\n\n```go\nconst (\n\tSourceUnknown   Source = \"unknown\"\n\tSourceWorkprint Source = \"workprint\"\n\tSourceCAM       Source = \"cam\"\n\tSourceTelesync  Source = \"telesync\"\n\tSourceTELECINE  Source = \"telecine\"\n\tSourceDVDSCR    Source = \"dvdscr\"\n\tSourceRegional  Source = \"regional\"\n\tSourceDVD       Source = \"dvd\"\n\tSourceDVDR      Source = \"dvdr\"\n\tSourceHDTV      Source = \"hdtv\"\n\tSourceWEBRip    Source = \"webrip\"\n\tSourceWEBDL     Source = \"webdl\"\n\tSourceBluRay    Source = \"bluray\"\n\tSourceRemux     Source = \"remux\"\n\tSourceBRDisk    Source = \"brdisk\"\n\tSourceRawHD     Source = \"rawhd\"\n)\n```\n\n```go\ntype TMDBInjectable interface {\n\tSetTMDBClient(client any)\n}\n```\nTMDBInjectable is an optional interface for import list plugins that need the shared TMDB client. The service calls SetTMDBClient before Fetch()/Test(). The parameter is typed as any to avoid an import cycle with internal/metadata/tmdb.\n\n```go\ntype TraktInjectable interface {\n\tSetTraktClient(client any)\n}\n```\nTraktInjectable is an optional interface for import list plugins that need the shared Trakt client. The service calls SetTraktClient before Fetch()/Test(). The parameter is typed as any to avoid an import cycle with internal/trakt.\n\n```go\ntype WatchEvent struct {\n\tTMDBID    int       // movie identifier\n\tTitle     string    // for display/logging\n\tWatchedAt time.Time // when playback completed\n\tUserName  string    // media server user (for multi-user setups)\n}\n```\nWatchEvent represents a single completed playback of a movie.\n\n```go\ntype WatchProvider interface {\n\t// WatchHistory returns watch events since the given timestamp.\n\t// Each event represents one completed playback (\u003e= 90% watched).\n\tWatchHistory(ctx context.Context, since time.Time) ([]WatchEvent, error)\n}\n```\nWatchProvider is an optional interface for media servers that can report watch history. Plugins that don't support it simply don't implement it. Check with a type assertion at runtime:\n\n\tif wp, ok := server.(WatchProvider); ok { ... }\n\n","path":"github.com/beacon-stack/prism/pkg/plugin","name":"plugin","synopsis":"Package plugin defines the public interfaces and value types for Prism's plugin system.","isRedistributable":true}
