arr

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
var Apps = []App{Radarr, Sonarr}

Apps lists the apps Matinee connects to.

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound means the app doesn't have the title.

Functions

func NormalizeURL

func NormalizeURL(raw string) (string, error)

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

func SettingKey(app App) string

SettingKey is the setting that holds an app's Config, as JSON.

Types

type AddOptions

type AddOptions struct {
	QualityProfileID int
	RootFolder       string
}

AddOptions say how to add a title.

type App

type App string

App is one of the apps Matinee connects to.

const (
	Radarr App = "radarr" // movies
	Sonarr App = "sonarr" // TV shows
)

func ParseApp

func ParseApp(s string) (App, bool)

ParseApp reads an app's name, as used in URLs.

func (App) Name

func (a App) Name() string

Name is the app's name as people know it.

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 New

func New(app App, c Config) (*Client, error)

func (*Client) Add

func (c *Client) Add(ctx context.Context, id int, opt AddOptions) (Title, error)

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

func (c *Client) BoxOfficeAskEdition(ctx context.Context, tmdbID int, edition, mode string) error

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

func (c *Client) BoxOfficeDiscoverSearch(ctx context.Context, q string) ([]BoxOfficeTitle, error)

BoxOfficeDiscoverSearch finds movies and shows by name.

func (*Client) BoxOfficeEditions added in v0.2.3

func (c *Client) BoxOfficeEditions(ctx context.Context, tmdbID int) (BoxOfficeEditions, error)

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

func (c *Client) BoxOfficeNotifications(ctx context.Context, after int64) (BoxOfficeFeed, error)

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

func (c *Client) Calendar(ctx context.Context, from, to time.Time) ([]Upcoming, error)

Calendar lists what's due between from and to that the app is waiting for: monitored titles without a file yet.

func (*Client) Find

func (c *Client) Find(ctx context.Context, tmdbID int, title string, year int) (Title, error)

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) Library added in v0.2.2

func (c *Client) Library(ctx context.Context) ([]Title, error)

Library lists every title the app has.

func (*Client) Lookup

func (c *Client) Lookup(ctx context.Context, id int) (Title, error)

Lookup describes one title, by TMDB id for movies or TVDB id for shows.

func (*Client) QualityProfiles

func (c *Client) QualityProfiles(ctx context.Context) ([]QualityProfile, error)

func (*Client) ReplaceEpisode

func (c *Client) ReplaceEpisode(ctx context.Context, seriesID, season, episode int) error

ReplaceEpisode deletes an episode's file and searches for another copy.

func (*Client) ReplaceMovie

func (c *Client) ReplaceMovie(ctx context.Context, movie Title) error

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

func (c *Client) Search(ctx context.Context, term string) ([]Title, error)

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

func (c *Client) SetQualityProfile(ctx context.Context, id, profileID int, search bool) error

SetQualityProfile changes a title's quality profile and, with search, looks for copies that match it.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (Status, error)

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.

func (*Client) URL

func (c *Client) URL() string

URL is the app's address, as Status found it.

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
	// contains filtered or unexported fields
}

Error is a failed call, with a message fit to show an admin.

func (*Error) Error

func (e *Error) Error() string

type QualityProfile

type QualityProfile struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type RootFolder

type RootFolder struct {
	Path      string `json:"path"`
	FreeSpace int64  `json:"freeSpace"`
}

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.

func (Status) BoxOffice added in v0.2.3

func (s Status) BoxOffice(feature string) bool

BoxOffice says whether the app is Box Office with a feature.

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).

func Match added in v0.2.2

func Match(list []Title, title string, year int) (Title, bool)

Match finds the title in list with this title, ignoring case and punctuation, and a year at most one off (when both have one).

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.

Directories

Path Synopsis
Package arrtest is a pretend Radarr or Sonarr for tests: just enough of their v3 API for what Matinee calls.
Package arrtest is a pretend Radarr or Sonarr for tests: just enough of their v3 API for what Matinee calls.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL