Documentation
¶
Overview ¶
Package arr is what the Sonarr and Radarr adapters share: their form, error classifier, history cursor, tags, root folders and the poster's two-zone fetch. arrapi v3's sonarr and radarr clients have no common type, so arr takes their values and functions, never a client.
Index ¶
- func AltTitles(primary string, titles []string) []string
- func AudioLangs(mi *arrapi.MediaInfo) []language.Tag
- func Changes(ctx context.Context, history History, cur mediasource.Cursor, log *slog.Logger) ([]mediasource.Change, mediasource.Cursor, error)
- func Classify(err error) *mediasource.SourceError
- func External(id int) uint64
- func ID(ref mediasource.NativeRef, kind media.Kind) (int, bool)
- func IMDb(id string) uint64
- func Native(id int) mediasource.NativeID
- func OriginalLang(l *arrapi.Language) language.Tag
- func RootFolders(paths []string) []string
- func Schema(app string) formschema.Schema
- func Tags(tags []arrapi.Tag) map[mediasource.TagRef]string
- type History
- type Poster
- type Record
- type Values
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AltTitles ¶
AltTitles drops empty titles and case-insensitive duplicates of primary and of each other, keeping the first of each in order.
func AudioLangs ¶
AudioLangs maps each audio track's language, in track order, through language.FromName, which reads the English names and the ISO 639-2 codes both API generations send, dropping unknown entries and duplicates.
func Changes ¶
func Changes(ctx context.Context, history History, cur mediasource.Cursor, log *slog.Logger) ([]mediasource.Change, mediasource.Cursor, error)
Changes answers an adapter's Changes over history, with one clock reading per call: a zero cursor takes the head and reports nothing; any other reports, once each, the root of every record in its re-read window whose id it has not seen. A record dated past the clock plus overlap counts for nothing until its date comes, with one WARN per call. An answer over arrapi's list cap, or an unreadable cursor, is Expired. A nil log is slog.Default.
func Classify ¶
func Classify(err error) *mediasource.SourceError
Classify maps an arrapi or transport error to a *SourceError, first matching row: a command outcome unknown, a server change, an unsupported API, a refused redirect, an answer too large or undecodable, a status code, else Unreachable, so a *arrapi.ServerChangedError is Unreachable whatever status it unwraps. Source and Op are the Set's to fill.
func ID ¶
ID is the arr id ref names under kind: false for another kind or an id that is not a positive canonical decimal, which no arr root has.
func Native ¶
func Native(id int) mediasource.NativeID
Native is an arr integer id's NativeID, its canonical decimal.
func OriginalLang ¶
OriginalLang is language.FromName of a language the arr names, an original or a metadata language; zero when absent or unknown.
func RootFolders ¶
RootFolders drops each folder's trailing slashes, which Sonarr and Radarr keep as the user typed them, so a folder meets the Set's path rule; any other unclean folder is left for the Set to drop.
func Schema ¶
func Schema(app string) formschema.Schema
Schema is the form both apps share: url and api_key required, public_url optional; app names the application in labels and help.
Types ¶
type History ¶
History reads every record dated at or after since in one request, oldest first: each adapter's HistorySince with its service's four kinds.
type Poster ¶
type Poster struct {
// contains filtered or unexported fields
}
Poster fetches a cover across two trust zones. The credentialed leg follows only same-origin redirects; its first cross-origin redirect is refetched with no header through the public leg, which reaches only public https addresses and never returns to the credentialed one.
func NewPoster ¶
NewPoster builds both legs: the credentialed one a copy of arr, nil meaning a zero client, and the public one over ssrf's transport with the same Timeout.
func (*Poster) Fetch ¶
func (p *Poster) Fetch(ctx context.Context, url, apiKey string) (body io.ReadCloser, contentType string, found bool, err error)
Fetch reads the whole cover at url, sending apiKey only to url's origin, before returning it with its content type, both legs inside ctx's deadline or, when it has none, 30 s. A 404 answers false; a body over maxPosterBytes is Protocol.
type Record ¶
type Record struct {
Date time.Time
Root mediasource.NativeRef
ID int
}
Record is one history record as Changes reads it: a download import, folder import, rename or file delete of Root.
type Values ¶
type Values struct{ URL, APIKey, PublicURL string }
Values is an arr entry's decoded settings.
func ReadValues ¶
func ReadValues(vals formschema.Values) (Values, error)
ReadValues reads an entry decoded by Schema, whose Required fields refuse an absent or empty url and api_key. It refuses a public_url that is not an absolute http or https URL with a host and no query or fragment, naming the rule and never the value; url is the arrapi client's to check, whose refusals name no URL or key either.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package arrtest serves a Sonarr's or Radarr's recorded answers to the adapters' tests, in process or over a socket, and checks a recording directory holds no credential.
|
Package arrtest serves a Sonarr's or Radarr's recorded answers to the adapters' tests, in process or over a socket, and checks a recording directory holds no credential. |