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 BoxOfficeLeaving
- type BoxOfficeMedia
- type BoxOfficeNotification
- type BoxOfficeProvider
- type BoxOfficeRequest
- type BoxOfficeRow
- type BoxOfficeTitle
- type BoxOfficeUpgrade
- type BoxOfficeWatch
- type BoxOfficeWatched
- 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) BoxOfficeApprove(ctx context.Context, id int64, profile int) (BoxOfficeRequest, error)
- func (c *Client) BoxOfficeAsk(ctx context.Context, user string, tmdbID int, approved bool, profile int) (BoxOfficeRequest, 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) BoxOfficeDecline(ctx context.Context, id int64, reply string) (BoxOfficeRequest, 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) BoxOfficeLeavingSoon(ctx context.Context) ([]BoxOfficeLeaving, error)
- func (c *Client) BoxOfficeNotifications(ctx context.Context, after int64) (BoxOfficeFeed, error)
- func (c *Client) BoxOfficeReportWatched(ctx context.Context, people int, titles []BoxOfficeWatched) error
- func (c *Client) BoxOfficeRequests(ctx context.Context, ids []int64) ([]BoxOfficeRequest, error)
- func (c *Client) BoxOfficeWhereToWatch(ctx context.Context, tmdbID int, country string) (BoxOfficeWatch, error)
- func (c *Client) BoxOfficeWithdraw(ctx context.Context, id int64) 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 BoxOfficeLeaving ¶ added in v0.2.11
type BoxOfficeLeaving struct {
TMDBID int `json:"tmdbId"`
TVDBID int `json:"tvdbId,omitempty"`
Title string `json:"title"`
Year int `json:"year,omitempty"`
LeavesAt time.Time `json:"leavesAt"`
}
BoxOfficeLeaving is a title Box Office's clean-up rules have listed as leaving soon. Its status says "leaving" when it has the list.
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 BoxOfficeProvider ¶ added in v0.2.11
type BoxOfficeProvider struct {
ID int64 `json:"id"`
Name string `json:"name"`
Logo string `json:"logo,omitempty"`
}
BoxOfficeProvider is a streaming service or shop, such as Netflix.
type BoxOfficeRequest ¶ added in v0.2.4
type BoxOfficeRequest struct {
ID int64 `json:"id"`
Kind string `json:"kind"` // movie or series
TMDBID int `json:"tmdbId"`
Title string `json:"title"`
// Status is pending, approved or declined, and Reply the admin's words
// for a declined one.
Status string `json:"status"`
Reply string `json:"reply,omitempty"`
// State is how far it's got: pending, declined, searching,
// downloading, partial, available, paused or removed.
State string `json:"state"`
}
BoxOfficeRequest is a request on Box Office's Requests page, as Box Office has it.
type BoxOfficeRow ¶ added in v0.2.3
type BoxOfficeRow struct {
ID string `json:"id"`
Title string `json:"title"`
// Because is the library title a because-{movie,series}-{tmdb id} row
// is based on.
Because string `json:"because,omitempty"`
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"`
// Problem is what someone reported with the copy, for want replace,
// to a Box Office with "problems": wrong, language, video or audio;
// Language is the language (ISO 639-1) the sound should be in, for
// language; ReportedBy is who reported it.
Problem string `json:"problem,omitempty"`
Language string `json:"language,omitempty"`
ReportedBy string `json:"reportedBy,omitempty"`
// FileName is the reported file's name, so Box Office leaves its copy
// alone when it isn't that file (the title matched wrong here).
FileName string `json:"fileName,omitempty"`
}
BoxOfficeUpgrade is what to ask Box Office for a title in the library.
type BoxOfficeWatch ¶ added in v0.2.11
type BoxOfficeWatch struct {
Networks []BoxOfficeProvider `json:"networks"`
Country string `json:"country"`
Link string `json:"link,omitempty"`
Stream []BoxOfficeProvider `json:"stream,omitempty"`
Free []BoxOfficeProvider `json:"free,omitempty"`
Rent []BoxOfficeProvider `json:"rent,omitempty"`
Buy []BoxOfficeProvider `json:"buy,omitempty"`
Countries []string `json:"countries"`
}
BoxOfficeWatch is where a title can be watched in one country, as Box Office tells it (from JustWatch, through TMDB): the networks a show is made for, then services by how they're paid for.
type BoxOfficeWatched ¶ added in v0.2.11
type BoxOfficeWatched struct {
TMDBID int `json:"tmdbId"`
LastPlayed *time.Time `json:"lastPlayed,omitempty"`
Viewers int `json:"viewers"`
FinishedBy int `json:"finishedBy"`
FinishedAt *time.Time `json:"finishedAt,omitempty"`
// FurthestSeason and FurthestEpisode are the latest episode of a show
// anyone has started, leaving specials out.
FurthestSeason int `json:"furthestSeason,omitempty"`
FurthestEpisode int `json:"furthestEpisode,omitempty"`
// AllFinishedSeason and AllFinishedEpisode are the latest episode of
// a show that everyone who has played any of it has finished, specials
// left out; Box Office can remove watched episodes up to it.
AllFinishedSeason int `json:"allFinishedSeason,omitempty"`
AllFinishedEpisode int `json:"allFinishedEpisode,omitempty"`
}
BoxOfficeWatched is how much one title has been watched, by everyone together: counts of people, never who.
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) BoxOfficeApprove ¶ added in v0.2.4
func (c *Client) BoxOfficeApprove(ctx context.Context, id int64, profile int) (BoxOfficeRequest, error)
BoxOfficeApprove approves a request on Box Office, with a quality profile or 0 for Box Office's.
func (*Client) BoxOfficeAsk ¶ added in v0.2.4
func (c *Client) BoxOfficeAsk(ctx context.Context, user string, tmdbID int, approved bool, profile int) (BoxOfficeRequest, error)
BoxOfficeAsk files a request on Box Office's Requests page for the Matinee account named user. approved says it's to be added at once (Matinee lets this person add titles); profile is a quality profile, or 0. Box Office's rules, such as weekly limits, come back as an *Error with Status 422 and the words for the person in Reason.
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) BoxOfficeDecline ¶ added in v0.2.4
func (c *Client) BoxOfficeDecline(ctx context.Context, id int64, reply string) (BoxOfficeRequest, error)
BoxOfficeDecline declines a request on Box Office.
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, because-{movie,series}-{tmdb id} (a title Box Office has), 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) BoxOfficeLeavingSoon ¶ added in v0.2.11
func (c *Client) BoxOfficeLeavingSoon(ctx context.Context) ([]BoxOfficeLeaving, error)
BoxOfficeLeavingSoon is this app's kind of title (movies as Radarr, shows as Sonarr) that's leaving soon, soonest first.
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) BoxOfficeReportWatched ¶ added in v0.2.11
func (c *Client) BoxOfficeReportWatched(ctx context.Context, people int, titles []BoxOfficeWatched) error
BoxOfficeReportWatched tells Box Office what has been watched of this app's kind of title (movies as Radarr, shows as Sonarr), and how many people there are. Each report replaces the last.
func (*Client) BoxOfficeRequests ¶ added in v0.2.4
BoxOfficeRequests is where requests on Box Office stand, by id. Ones Box Office no longer has are left out.
func (*Client) BoxOfficeWhereToWatch ¶ added in v0.2.11
func (c *Client) BoxOfficeWhereToWatch(ctx context.Context, tmdbID int, country string) (BoxOfficeWatch, error)
BoxOfficeWhereToWatch asks where a title can be watched in country (Box Office's own when ""): a movie of Radarr's, a show of Sonarr's.
func (*Client) BoxOfficeWithdraw ¶ added in v0.2.4
BoxOfficeWithdraw takes back a request on Box Office that's still waiting there.
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 Error ¶
type Error struct {
Status int
Message string
// Reason is the app's own words, without its name, when it gave any.
Reason string
// contains filtered or unexported fields
}
Error is a failed call, with a message fit to show an admin.
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.