Documentation
¶
Overview ¶
Package arr talks to Radarr (movies) and Sonarr (TV), the apps many people run next to their media server to find and download what they watch. Matinee uses them to add titles people ask for, list what's coming soon, change a title's quality profile and replace a bad file.
It's a built-in integration. Everything Matinee needs from these apps goes through Client, so the rest of the server doesn't know their APIs, and the integration can move behind the plugin framework later without the HTTP API changing.
Index ¶
- Variables
- func NormalizeURL(raw string) (string, error)
- func SettingKey(app App) string
- type AddOptions
- type App
- type BoxOfficeActivity
- type BoxOfficeActivityItem
- type BoxOfficeDiscover
- type BoxOfficeEdition
- type BoxOfficeEditions
- type BoxOfficeFeed
- type BoxOfficeMedia
- type BoxOfficeNotification
- type BoxOfficeRow
- type BoxOfficeTitle
- type BoxOfficeUpgrade
- type Client
- func (c *Client) Add(ctx context.Context, id int, opt AddOptions) (Title, error)
- func (c *Client) BoxOfficeActivity(ctx context.Context) (BoxOfficeActivity, error)
- func (c *Client) BoxOfficeAskEdition(ctx context.Context, tmdbID int, edition, mode string) error
- func (c *Client) BoxOfficeAskUpgrade(ctx context.Context, u BoxOfficeUpgrade) error
- func (c *Client) BoxOfficeDiscoverHome(ctx context.Context) (BoxOfficeDiscover, error)
- func (c *Client) BoxOfficeDiscoverRow(ctx context.Context, id string, page int) (BoxOfficeRow, error)
- func (c *Client) BoxOfficeDiscoverSearch(ctx context.Context, q string) ([]BoxOfficeTitle, error)
- func (c *Client) BoxOfficeEditions(ctx context.Context, tmdbID int) (BoxOfficeEditions, error)
- func (c *Client) BoxOfficeNotifications(ctx context.Context, after int64) (BoxOfficeFeed, error)
- func (c *Client) Calendar(ctx context.Context, from, to time.Time) ([]Upcoming, error)
- func (c *Client) Find(ctx context.Context, tmdbID int, title string, year int) (Title, error)
- func (c *Client) Library(ctx context.Context) ([]Title, error)
- func (c *Client) Lookup(ctx context.Context, id int) (Title, error)
- func (c *Client) QualityProfiles(ctx context.Context) ([]QualityProfile, error)
- func (c *Client) ReplaceEpisode(ctx context.Context, seriesID, season, episode int) error
- func (c *Client) ReplaceMovie(ctx context.Context, movie Title) error
- func (c *Client) RootFolders(ctx context.Context) ([]RootFolder, error)
- func (c *Client) Search(ctx context.Context, term string) ([]Title, error)
- func (c *Client) SetQualityProfile(ctx context.Context, id, profileID int, search bool) error
- func (c *Client) Status(ctx context.Context) (Status, error)
- func (c *Client) URL() string
- type Config
- type Error
- type QualityProfile
- type RootFolder
- type Status
- type Title
- type Upcoming
Constants ¶
This section is empty.
Variables ¶
var Apps = []App{Radarr, Sonarr}
Apps lists the apps Matinee connects to.
var ErrNotFound = errors.New("not found")
ErrNotFound means the app doesn't have the title.
Functions ¶
func NormalizeURL ¶
NormalizeURL accepts an address the way people type it, such as "radarr:7878" or "https://example.com/sonarr/".
func SettingKey ¶ added in v0.2.2
SettingKey is the setting that holds an app's Config, as JSON.
Types ¶
type AddOptions ¶
AddOptions say how to add a title.
type BoxOfficeActivity ¶ added in v0.2.3
type BoxOfficeActivity struct {
BoxOfficeID string `json:"boxOfficeId"`
Speed int64 `json:"speed"` // bytes a second
Waiting string `json:"waiting,omitempty"`
Items []BoxOfficeActivityItem `json:"items"`
}
BoxOfficeActivity is what Box Office is downloading, and what just finished or went wrong.
type BoxOfficeActivityItem ¶ added in v0.2.3
type BoxOfficeActivityItem struct {
ID int64 `json:"id"`
Kind string `json:"kind"` // movie or series
TMDBID int `json:"tmdbId,omitempty"`
TVDBID int `json:"tvdbId,omitempty"`
IMDBID string `json:"imdbId,omitempty"`
Title string `json:"title"`
Year int `json:"year,omitempty"`
Poster string `json:"poster,omitempty"`
Episodes []struct {
Season int `json:"seasonNumber"`
Episode int `json:"episodeNumber"`
} `json:"episodes,omitempty"`
// Stage is queued, downloading, paused, waiting, checking, repairing,
// unpacking, importing, waitingToMove, imported, failed or quarantined.
Stage string `json:"stage"`
Percent float64 `json:"percent"`
Size int64 `json:"size"`
DoneBytes int64 `json:"doneBytes"`
ETA int64 `json:"etaSeconds,omitempty"`
Quality string `json:"quality,omitempty"`
Edition string `json:"edition,omitempty"`
Mode string `json:"mode,omitempty"`
Message string `json:"message,omitempty"`
AddedAt time.Time `json:"addedAt"`
UpdatedAt time.Time `json:"updatedAt,omitzero"`
}
BoxOfficeActivityItem is one download.
type BoxOfficeDiscover ¶ added in v0.2.3
type BoxOfficeDiscover struct {
Rows []BoxOfficeRow `json:"rows"`
}
BoxOfficeDiscover is Box Office's Discover home.
type BoxOfficeEdition ¶ added in v0.2.3
type BoxOfficeEdition struct {
Edition string `json:"edition"`
Releases int `json:"releases"`
Quality string `json:"quality,omitempty"`
Size int64 `json:"size,omitempty"`
Owned bool `json:"owned,omitempty"`
}
BoxOfficeEdition is one edition of a movie the indexers have.
type BoxOfficeEditions ¶ added in v0.2.3
type BoxOfficeEditions struct {
MovieID int `json:"movieId"`
HasFile bool `json:"hasFile"`
Current string `json:"current,omitempty"`
Alongside []string `json:"alongside,omitempty"`
Editions []BoxOfficeEdition `json:"editions"`
Errors []string `json:"errors,omitempty"`
}
BoxOfficeEditions is a movie's editions: those found, the one its copy is ("" when its name doesn't say), and those kept next to it.
type BoxOfficeFeed ¶ added in v0.2.3
type BoxOfficeFeed struct {
BoxOfficeID string `json:"boxOfficeId"`
Last int64 `json:"last"` // the newest id there is
Notifications []BoxOfficeNotification `json:"notifications"`
}
BoxOfficeFeed is a page of the feed.
type BoxOfficeMedia ¶ added in v0.2.3
type BoxOfficeMedia struct {
Kind string `json:"kind"` // movie or series
Title string `json:"title"`
Year int `json:"year,omitempty"`
TMDBID int `json:"tmdbId,omitempty"`
TVDBID int `json:"tvdbId,omitempty"`
IMDBID string `json:"imdbId,omitempty"`
Season int `json:"season,omitempty"`
Episodes []int `json:"episodes,omitempty"`
Poster string `json:"poster,omitempty"`
}
BoxOfficeMedia is the title a notification is about.
type BoxOfficeNotification ¶ added in v0.2.3
type BoxOfficeNotification struct {
ID int64 `json:"id"`
Event string `json:"event"` // download.grabbed, download.imported, download.completed, download.failed, download.quarantined…
Level string `json:"level"` // info, warning, critical
// Audience is "everyone" (the people who asked for the title, and
// admins) or "admins".
Audience string `json:"audience"`
Title string `json:"title"`
Body string `json:"body,omitempty"`
Media *BoxOfficeMedia `json:"media,omitempty"`
At time.Time `json:"at"`
}
BoxOfficeNotification is one entry in Box Office's feed.
type BoxOfficeRow ¶ added in v0.2.3
type BoxOfficeRow struct {
ID string `json:"id"`
Title string `json:"title"`
Items []BoxOfficeTitle `json:"items"`
More bool `json:"more,omitempty"`
// Page and Pages are set on a row read by itself.
Page int `json:"page,omitempty"`
Pages int `json:"pages,omitempty"`
}
BoxOfficeRow is one of Box Office's Discover rows.
type BoxOfficeTitle ¶ added in v0.2.3
type BoxOfficeTitle struct {
Kind string `json:"kind"` // movie or series
TMDBID int `json:"tmdbId"`
Title string `json:"title"`
Year int `json:"year,omitempty"`
Overview string `json:"overview,omitempty"`
Poster string `json:"poster,omitempty"`
Backdrop string `json:"backdrop,omitempty"`
Rating float64 `json:"rating,omitempty"`
// Status is where Box Office has it: available (on disk), partial (a
// show with some episodes), wanted, paused, or empty when it doesn't.
Status string `json:"status,omitempty"`
}
BoxOfficeTitle is a title in one of Box Office's Discover rows.
type BoxOfficeUpgrade ¶ added in v0.2.3
type BoxOfficeUpgrade struct {
TMDBID int `json:"tmdbId,omitempty"` // a movie
TVDBID int `json:"tvdbId,omitempty"` // a show's episode, with Season and Episode
Season int `json:"seasonNumber,omitempty"`
Episode int `json:"episodeNumber,omitempty"`
Want string `json:"want"` // better, or replace (the copy there is bad)
Reason string `json:"reason,omitempty"`
}
BoxOfficeUpgrade is what to ask Box Office for a title in the library.
type Client ¶
type Client struct {
App App
// contains filtered or unexported fields
}
Client calls one app's API (v3, which current Radarr and Sonarr both serve).
func (*Client) Add ¶
Add adds a title, by TMDB id for movies or TVDB id for shows, and starts searching for it. A title the app already has is left as it is.
func (*Client) BoxOfficeActivity ¶ added in v0.2.3
func (c *Client) BoxOfficeActivity(ctx context.Context) (BoxOfficeActivity, error)
BoxOfficeActivity reads what Box Office is downloading.
func (*Client) BoxOfficeAskEdition ¶ added in v0.2.3
BoxOfficeAskEdition has Box Office get an edition of a movie, to replace its copy (mode "replace") or go alongside it ("alongside").
func (*Client) BoxOfficeAskUpgrade ¶ added in v0.2.3
func (c *Client) BoxOfficeAskUpgrade(ctx context.Context, u BoxOfficeUpgrade) error
BoxOfficeAskUpgrade has Box Office look for a better copy, or another one for a bad one.
func (*Client) BoxOfficeDiscoverHome ¶ added in v0.2.3
func (c *Client) BoxOfficeDiscoverHome(ctx context.Context) (BoxOfficeDiscover, error)
BoxOfficeDiscoverHome reads Box Office's Discover rows.
func (*Client) BoxOfficeDiscoverRow ¶ added in v0.2.3
func (c *Client) BoxOfficeDiscoverRow(ctx context.Context, id string, page int) (BoxOfficeRow, error)
BoxOfficeDiscoverRow reads a page (from 1) of one row: trending, popular-movies, popular-series, upcoming-movies, upcoming-series, for-you, or like-{movie,series}-{tmdb id}.
func (*Client) BoxOfficeDiscoverSearch ¶ added in v0.2.3
BoxOfficeDiscoverSearch finds movies and shows by name.
func (*Client) BoxOfficeEditions ¶ added in v0.2.3
BoxOfficeEditions searches for a movie's editions, by TMDB id. It takes a few seconds: Box Office asks its indexers.
func (*Client) BoxOfficeNotifications ¶ added in v0.2.3
BoxOfficeNotifications reads Box Office's feed after an id, oldest first. after=-1 reads only where the feed is (Last), skipping what's there already.
func (*Client) Calendar ¶
Calendar lists what's due between from and to that the app is waiting for: monitored titles without a file yet.
func (*Client) Find ¶
Find looks for a title the app already has: by TMDB id, else by title and year (for libraries looked up without TMDB, and Sonarr versions that don't know TMDB ids).
func (*Client) QualityProfiles ¶
func (c *Client) QualityProfiles(ctx context.Context) ([]QualityProfile, error)
func (*Client) ReplaceEpisode ¶
ReplaceEpisode deletes an episode's file and searches for another copy.
func (*Client) ReplaceMovie ¶
ReplaceMovie deletes a movie's file and searches for another copy.
func (*Client) RootFolders ¶
func (c *Client) RootFolders(ctx context.Context) ([]RootFolder, error)
func (*Client) Search ¶
Search looks titles up online through the app, the way its own Add New page does. Titles the app already has come back with their ID set.
func (*Client) SetQualityProfile ¶
SetQualityProfile changes a title's quality profile and, with search, looks for copies that match it.
func (*Client) Status ¶
Status checks the address and key reach the app this client is for.
When the app redirects to its own URL base on the same host (or from http to https there), the client moves to that address; URL then reports it. Redirects elsewhere aren't followed, since they'd carry the API key along.
type Config ¶
type Config struct {
URL string `json:"url"`
APIKey string `json:"apiKey"`
// What titles added from Matinee get, unless whoever adds one picks another profile.
QualityProfileID int `json:"qualityProfileId"`
RootFolder string `json:"rootFolder"`
}
Config is how Matinee reaches one app, set by an admin. The API key stays on the server.
type QualityProfile ¶
type RootFolder ¶
type Status ¶
type Status struct {
AppName string `json:"appName"`
Version string `json:"version"`
// BoxOfficeID is set when the app is Box Office (github.com/yeixio/boxoffice)
// answering as Radarr or Sonarr: the same id on both, so Matinee knows
// they're one server.
BoxOfficeID string `json:"boxOfficeId,omitempty"`
// BoxOfficeFeatures lists what that Box Office adds to the API, such as
// "notifications".
BoxOfficeFeatures []string `json:"boxOfficeFeatures,omitempty"`
}
Status is what an app says about itself.
type Title ¶
type Title struct {
ID int `json:"-"` // the app's own id; 0 when it hasn't added the title
TMDBID int `json:"tmdbId,omitempty"`
TVDBID int `json:"tvdbId,omitempty"`
Title string `json:"title"`
Year int `json:"year,omitempty"`
Overview string `json:"overview,omitempty"`
Poster string `json:"poster,omitempty"`
Backdrop string `json:"backdrop,omitempty"`
// Rating is out of 10; Genres are in English.
Rating float64 `json:"-"`
Genres []string `json:"-"`
QualityProfileID int `json:"-"`
HasFile bool `json:"-"` // a movie's file is there
FileID int `json:"-"`
}
Title is a movie (Radarr) or show (Sonarr).
type Upcoming ¶
type Upcoming struct {
Kind string `json:"kind"` // movie or episode
Title string `json:"title"`
Year int `json:"year,omitempty"`
ShowTitle string `json:"showTitle,omitempty"`
Season *int `json:"season,omitempty"`
Episode *int `json:"episode,omitempty"`
Date time.Time `json:"date"`
// Release says what happens on Date: for movies cinemas, digital or
// physical; for episodes airs.
Release string `json:"release"`
Overview string `json:"overview,omitempty"`
Poster string `json:"poster,omitempty"`
TMDBID int `json:"tmdbId,omitempty"`
}
Upcoming is a movie release or an episode airing.