arr

package
v0.10.0-dev.21 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: AGPL-3.0 Imports: 18 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

View Source
const MaxPosterBytes = 2 << 20

MaxPosterBytes bounds one poster; a larger one is refused, never cut.

Variables

This section is empty.

Functions

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, a status code, else Unreachable, so a *arrapi.ServerChangedError is Unreachable whatever status it unwraps. Source and Op are the Set's to fill. A decode failure reads Unreachable: arrapi v3.1.0 exports no decode error.

func Native

func Native(id int) mediasource.NativeID

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

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.

Jump to

Keyboard shortcuts

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