Documentation
¶
Overview ¶
Package medialib provides higher-level abstractions for media library services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found in library")
ErrNotFound is returned when a media item is not found in the library.
var ErrNotUpgrade = errors.New("existing library file is already an equal or better version")
ErrNotUpgrade is returned when an import scan reports no successful imports because the file already in the library is as good or better than the file being imported (the arr service rejected the release as "not an upgrade" / "not a Custom Format upgrade"). The import can never succeed, so callers should treat this as a benign skip rather than a retryable failure.
Functions ¶
This section is empty.
Types ¶
type ArrLibrary ¶
type ArrLibrary interface {
// ImportByFilePath translates path to the arr service's view and sends a
// DownloadedMoviesScan (Radarr) or DownloadedEpisodesScan (Sonarr) command,
// triggering the arr service's normal download-completion import pipeline.
// expectedSize is the size of the local source file in bytes. It is used
// as a post-check tiebreaker when the scan command finishes with no
// successful imports: if the library item's stored file matches
// expectedSize, the import is treated as having succeeded (typically
// because the arr service's own completed-download handler raced our
// scan). A non-positive expectedSize disables the post-check.
//
// Returns ErrNotFound when the scan reports no successful imports, the arr
// has no queue entry for the download, and the release name parses but
// matches nothing in the library (removed or no longer monitored), so the
// import can never succeed. A name that can't be parsed at all is not
// reported as ErrNotFound: that says nothing about the library. Returns ErrNotUpgrade when the scan
// reports no successful imports because the library already holds an equal
// or better file (the release was rejected as "not an upgrade"). Callers
// should treat both as a benign skip rather than a retryable failure.
ImportByFilePath(ctx context.Context, path string, expectedSize int64) error
// GetInfo returns structured media metadata for the item at path.
// Returns ErrNotFound if no item is identified.
GetInfo(ctx context.Context, path string) (MediaInfo, error)
// GetPosterImage returns the raw poster image bytes and MIME type for the
// media item at path. Returns ErrNotFound if the media item at path cannot
// be identified in the library. Returns nil bytes and empty MIME type (with
// no error) when a media item is found but no poster is available or the
// image type is not JPEG or PNG. Other errors indicate the library service
// is unreachable or returned an unexpected failure.
GetPosterImage(ctx context.Context, path string) (imageBytes []byte, mimeType string, err error)
}
ArrLibrary is a unified interface for refreshing a media item in the backing library service (Radarr for movies, Sonarr for shows). It abstracts the type-specific lookup-and-refresh calls so workflow steps need no media-type switch.
type Episode ¶
type Episode struct {
// contains filtered or unexported fields
}
Episode represents an episode entry in a TV library service. Construct with NewEpisode.
func NewEpisode ¶ added in v0.0.6
func NewEpisode(id, seriesID int64, title, seriesTitle string, year, seasonNumber, episodeNumber int) *Episode
NewEpisode returns an Episode populated with the supplied metadata. id and seriesID are the internal database IDs assigned by the backing TV library service. year is the series premiere year.
func (*Episode) GetEpisodeNumber ¶
GetEpisodeNumber returns the episode's episode number.
func (*Episode) GetSeasonNumber ¶
GetSeasonNumber returns the episode's season number.
func (*Episode) GetSeriesTitle ¶
GetSeriesTitle returns the episode's series title.
type MediaInfo ¶
type MediaInfo interface {
GetID() int64
GetTitle() string
GetYear() int
GetSeriesTitle() string // movies return ""
GetSeasonNumber() int // movies return 0
GetEpisodeNumber() int // movies return 0
}
MediaInfo exposes typed getters for per-media metadata.
type MediaType ¶
type MediaType string
MediaType identifies whether a media file is a movie or a TV show episode.
func AllMediaTypes ¶ added in v0.0.6
func AllMediaTypes() []MediaType
AllMediaTypes returns the canonical list of valid MediaType values. It is the single source of truth shared by runtime validation and JSON Schema generation.
func (MediaType) JSONSchema ¶
func (MediaType) JSONSchema() *jsonschema.Schema
JSONSchema returns a JSON Schema for MediaType restricting values to the valid types.
type Movie ¶
type Movie struct {
// contains filtered or unexported fields
}
Movie represents a movie entry in a movie library service. Construct with NewMovie.
func NewMovie ¶ added in v0.0.6
NewMovie returns a Movie populated with the supplied metadata. id is the internal database ID assigned by the backing movie library service.
func (*Movie) GetEpisodeNumber ¶
GetEpisodeNumber returns 0 for movies.
func (*Movie) GetSeasonNumber ¶
GetSeasonNumber returns 0 for movies.
func (*Movie) GetSeriesTitle ¶
GetSeriesTitle returns "" for movies.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
arrcommand
Package arrcommand provides shared polling logic for waiting on Sonarr/Radarr long-running commands (e.g.
|
Package arrcommand provides shared polling logic for waiting on Sonarr/Radarr long-running commands (e.g. |
|
artwork
Package artwork provides shared utilities for fetching poster images from arr-style media library services (Radarr, Sonarr).
|
Package artwork provides shared utilities for fetching poster images from arr-style media library services (Radarr, Sonarr). |
|
trackeddownload
Package trackeddownload finds the Sonarr/Radarr queue entry (the "tracked download") that a transcoded file belongs to, and holds the shared rules for deciding when a file can't be identified.
|
Package trackeddownload finds the Sonarr/Radarr queue entry (the "tracked download") that a transcoded file belongs to, and holds the shared rules for deciding when a file can't be identified. |
|
Package radarr provides a Radarr client implementing medialib.ArrLibrary.
|
Package radarr provides a Radarr client implementing medialib.ArrLibrary. |
|
Package sonarr provides a Sonarr client implementing medialib.ArrLibrary.
|
Package sonarr provides a Sonarr client implementing medialib.ArrLibrary. |