Documentation ¶
Overview ¶
Package starr is a library for interacting with the APIs in Radarr, Lidarr, Sonarr and Readarr. It consists of the main starr package and one sub package for each starr application. In the basic use, you create a starr Config that contains an API key and an App URL. Pass this into one of the other packages (like radarr), and it's used as an interface to make API calls.
You can either call starr.New() to build an http.Client for you, or create a starr.Config that contains one you control. If you pass a starr.Config into a sub package without an http Client, it will be created for you. There are a lot of option to set this code up from simple and easy to more advanced.
The sub package contain methods and data structures for a number of API endpoints. Each app has somewhere between 50 and 100 API endpoints. This library currently covers about 10% of those. You can retrieve things like movies, albums, series and books. You can retrieve server status, authors, artists and items in queues. You can also add new media to each application with this library.
Index ¶
- Constants
- Variables
- type APIer
- type App
- type BaseQuality
- type Config
- func (c *Config) Delete(path string, params url.Values) ([]byte, error)
- func (c *Config) DeleteInto(path string, params url.Values, v interface{}) error
- func (c *Config) Get(path string, params url.Values) ([]byte, error)
- func (c *Config) GetInto(path string, params url.Values, v interface{}) error
- func (c *Config) Post(path string, params url.Values, body []byte) ([]byte, error)
- func (c *Config) PostInto(path string, params url.Values, body []byte, v interface{}) error
- func (c *Config) Put(path string, params url.Values, body []byte) ([]byte, error)
- func (c *Config) PutInto(path string, params url.Values, body []byte, v interface{}) error
- type Duration
- type Image
- type IsLoaded
- type KeyValue
- type Link
- type Path
- type Quality
- type QualityRevision
- type Ratings
- type StatusMessage
- type Tag
- type Value
Constants ¶
const (
DefaultTimeout = 10 * time.Second
)
Defaults for New().
Variables ¶
var ( // ErrInvalidStatusCode is returned when the server (*arr app) returns a bad status code during an API request. ErrInvalidStatusCode = fmt.Errorf("invalid status code, <200||>299") // ErrNilClient is returned if you attempt a request with a nil http.Client. ErrNilClient = fmt.Errorf("http.Client must not be nil") // ErrNilInterface is returned by *Into() methods when a nil interface is provided. ErrNilInterface = fmt.Errorf("cannot unmarshal data into a nil or empty interface") )
Errors you may receive from this package.
Functions ¶
This section is empty.
Types ¶
type APIer ¶ added in v0.9.9
type APIer interface { Get(path string, params url.Values) ([]byte, error) Post(path string, params url.Values, body []byte) ([]byte, error) Put(path string, params url.Values, body []byte) ([]byte, error) Delete(path string, params url.Values) ([]byte, error) GetInto(path string, params url.Values, v interface{}) error PostInto(path string, params url.Values, body []byte, v interface{}) error PutInto(path string, params url.Values, body []byte, v interface{}) error DeleteInto(path string, params url.Values, v interface{}) error }
APIer is used by the sub packages to allow mocking the http methods in tests.
type App ¶ added in v0.10.4
type App string
App can be used to satisfy a context value key. It is not used in this library; provided for convenience.
const ( Emby App = "Emby" Lidarr App = "Lidarr" Plex App = "Plex" Prowlarr App = "Prowlarr" Radarr App = "Radarr" Readarr App = "Readarr" Sonarr App = "Sonarr" )
These constants are just here for convenience. If you add more here, add them to String() below.
type BaseQuality ¶ added in v0.9.11
type BaseQuality struct { ID int64 `json:"id"` Name string `json:"name"` Source string `json:"source,omitempty"` Resolution int `json:"resolution,omitempty"` Modifier string `json:"modifier,omitempty"` }
BaseQuality is a base quality profile.
type Config ¶
type Config struct { APIKey string `json:"api_key" toml:"api_key" xml:"api_key" yaml:"api_key"` URL string `json:"url" toml:"url" xml:"url" yaml:"url"` HTTPPass string `json:"http_pass" toml:"http_pass" xml:"http_pass" yaml:"http_pass"` HTTPUser string `json:"http_user" toml:"http_user" xml:"http_user" yaml:"http_user"` Timeout Duration `json:"timeout" toml:"timeout" xml:"timeout" yaml:"timeout"` ValidSSL bool `json:"valid_ssl" toml:"valid_ssl" xml:"valid_ssl" yaml:"valid_ssl"` Client *http.Client `json:"-" toml:"-" xml:"-" yaml:"-"` }
Config is the data needed to poll Radarr or Sonarr or Lidarr or Readarr. At a minimum, provide a URL and API Key. Set ValidSSL to true if the app has a valid SSL certificate. HTTPUser and HTTPPass are used for Basic HTTP auth, if enabled (not common). Timeout and ValidSSL are used to create the http Client by sub packages. You may set those and call New() in the sub packages to create the http.Client pointer, or you can create your own http.Client before calling subpackage.New().
func New ¶ added in v0.9.9
New returns a *starr.Config pointer. This pointer is safe to modify further before passing it into one of the arr app New() procedures.
func (*Config) DeleteInto ¶ added in v0.9.9
DeleteInto performs an HTTP DELETE against an API path and unmarshals the payload into a pointer interface.
func (*Config) GetInto ¶ added in v0.9.9
GetInto performs an HTTP GET against an API path and unmarshals the payload into the provided pointer interface.
func (*Config) PostInto ¶ added in v0.9.9
PostInto performs an HTTP POST against an API path and unmarshals the payload into the provided pointer interface.
type Duration ¶
Duration is used to Unmarshal text into a time.Duration value.
func (*Duration) UnmarshalText ¶
UnmarshalText parses a duration type from a config file.
type Image ¶ added in v0.9.9
type Image struct { CoverType string `json:"coverType"` URL string `json:"url"` RemoteURL string `json:"remoteUrl,omitempty"` Extension string `json:"extension,omitempty"` }
Image is used in a few places.
type IsLoaded ¶ added in v0.9.9
type IsLoaded struct {
IsLoaded bool `json:"isLoaded"`
}
IsLoaded is a generic struct used in a few places.
type Quality ¶ added in v0.9.4
type Quality struct { Name string `json:"name,omitempty"` ID int `json:"id,omitempty"` Quality *BaseQuality `json:"quality,omitempty"` Items []*Quality `json:"items"` Allowed bool `json:"allowed"` Revision *QualityRevision `json:"revision,omitempty"` // Not sure which app had this.... }
Quality is a download quality profile attached to a movie, book, track or series. It may contain 1 or more profiles. Readarr does not use Name or ID in this struct.
type QualityRevision ¶ added in v0.9.11
type QualityRevision struct { Version int64 `json:"version"` Real int64 `json:"real"` IsRepack bool `json:"isRepack,omitempty"` }
QualityRevision is probably used in Sonarr.
type Ratings ¶ added in v0.9.9
type Ratings struct { Votes int64 `json:"votes"` Value float64 `json:"value"` Popularity float64 `json:"popularity,omitempty"` }
Ratings belong to a few types.
type StatusMessage ¶ added in v0.9.4
StatusMessage represents the status of the item. All apps use this.