arr

package
v0.10.0-dev.49 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AltTitles

func AltTitles(primary string, titles []string) []string

AltTitles drops empty titles and case-insensitive duplicates of primary and of each other, keeping the first of each in order.

func AudioLangs

func AudioLangs(mi *arrapi.MediaInfo) []language.Tag

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

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 External

func External(id int) uint64

External is an arr's TVDB or TMDB id as an external id, 0 (unknown) below 1.

func ID

func ID(ref mediasource.NativeRef, kind media.Kind) (int, bool)

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 IMDb

func IMDb(id string) uint64

IMDb reads "tt" followed by decimal digits; anything else is 0, unknown.

func Native

func Native(id int) mediasource.NativeID

Native is an arr integer id's NativeID, its canonical decimal.

func OriginalLang

func OriginalLang(l *arrapi.Language) language.Tag

OriginalLang is language.FromName of a language the arr names, an original or a metadata language; zero when absent or unknown.

func RootFolders

func RootFolders(paths []string) []string

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.

func Tags

func Tags(tags []arrapi.Tag) map[mediasource.TagRef]string

Tags keys every tag by its decimal id; the Set matches its labels.

Types

type History

type History func(ctx context.Context, since time.Time) ([]Record, error)

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

func NewPoster(arr *http.Client) *Poster

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.

func (Values) LinkBase

func (v Values) LinkBase() string

LinkBase is the base a root's Link is built under: public_url, else url.

type Version

type Version struct {
	// contains filtered or unexported fields
}

Version logs the server version a Ping found, once per change. Its zero value is ready; it is safe for concurrent use.

func (*Version) Note

func (v *Version) Note(log *slog.Logger, version string, api arrapi.API)

Note logs version and api at INFO when version differs from the last one noted.

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.

Jump to

Keyboard shortcuts

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