apps

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

Package apps provides the _incoming_ HTTP methods for notifiarr.com integrations. Methods are included for Radarr, Readrr, Lidarr and Sonarr. This library also holds the site API Key and the base HTTP server abstraction used throughout the Notifiarr client application. The configuration should be derived from a config file; a Router and an Error Log logger must also be provided.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTMDB     = errors.New("TMDB ID must not be empty")
	ErrNoGRID     = errors.New("GRID ID must not be empty")
	ErrNoTVDB     = errors.New("TVDB ID must not be empty")
	ErrNoMBID     = errors.New("MBID ID must not be empty")
	ErrNoRadarr   = fmt.Errorf("configured %s ID not found", starr.Radarr)
	ErrNoSonarr   = fmt.Errorf("configured %s ID not found", starr.Sonarr)
	ErrNoLidarr   = fmt.Errorf("configured %s ID not found", starr.Lidarr)
	ErrNoReadarr  = fmt.Errorf("configured %s ID not found", starr.Readarr)
	ErrNoProwlarr = fmt.Errorf("configured %s ID not found", starr.Prowlarr)
	ErrNotFound   = errors.New("the request returned an empty payload")
	ErrNonZeroID  = errors.New("provided ID must be non-zero")
	// ErrWrongCount is returned when an app returns the wrong item count.
	ErrWrongCount = errors.New("wrong item count returned")
	ErrInvalidApp = errors.New("invalid application configuration provided")
	ErrRateLimit  = errors.New("rate limit reached")
)

Errors sent to client web requests.

Functions

func CheckURLs added in v0.9.0

func CheckURLs(config *AppsConfig) error

CheckURLs validates the configuration for each app.

func NewFakeCloser added in v0.4.1

func NewFakeCloser(app, method string, body io.ReadCloser) io.ReadCloser

Types

type APIHandler

type APIHandler func(r *http.Request) (int, any)

APIHandler is our custom handler function for APIs. The powers the middleware procedure that stores the app interface in a request context. And the procedures to save and fetch an app interface into/from a request content.

type ApiResponse added in v0.9.0

type ApiResponse struct {
	// The status always matches the HTTP response.
	Status string `json:"status"`
	// This message contains the request-specific response payload.
	Msg any `json:"message"`
}

ApiResponse is a standard response to our caller. JSON encoded blobs.

type Apps

type Apps struct {
	BaseConfig
	Lidarr       []Lidarr
	Radarr       []Radarr
	Readarr      []Readarr
	Sonarr       []Sonarr
	Prowlarr     []Prowlarr
	Deluge       []Deluge
	NZBGet       []NZBGet
	Qbit         []Qbit
	Rtorrent     []Rtorrent
	SabNZB       []SabNZB
	Transmission []Xmission
	Tautulli     Tautulli
	Plex         Plex
	Router       *mux.Router
	// contains filtered or unexported fields
}

func New added in v0.9.0

func New(config *AppsConfig) (*Apps, error)

New creates request interfaces and sets the timeout for each server. This is part of the config/startup init.

func (*Apps) CheckAPIKey

func (a *Apps) CheckAPIKey(next http.Handler) http.HandlerFunc

CheckAPIKey drops a 403 if the API key doesn't match, otherwise run next handler.

func (*Apps) HandleAPIpath

func (a *Apps) HandleAPIpath(app starr.App, uri string, api APIHandler, method ...string) *mux.Route

HandleAPIpath makes adding APIKey authenticated API paths a little cleaner. An empty App may be passed in, but URI, API and at least one method are required. Automatically adds an id route to routes with an app name. In case you have > 1 of that app.

func (*Apps) InitHandlers

func (a *Apps) InitHandlers()

InitHandlers activates all our handlers. This is part of the web server init.

func (*Apps) Respond

func (a *Apps) Respond(reqID string, w http.ResponseWriter, stat int, msg any) int64

Respond sends a standard response to our caller. JSON encoded blobs. Returns size of data sent.

type AppsConfig added in v0.9.0

type AppsConfig struct {
	BaseConfig
	Sonarr       []StarrConfig    `json:"sonarr,omitempty"       toml:"sonarr"       xml:"sonarr"       yaml:"sonarr,omitempty"`
	Radarr       []StarrConfig    `json:"radarr,omitempty"       toml:"radarr"       xml:"radarr"       yaml:"radarr,omitempty"`
	Lidarr       []StarrConfig    `json:"lidarr,omitempty"       toml:"lidarr"       xml:"lidarr"       yaml:"lidarr,omitempty"`
	Readarr      []StarrConfig    `json:"readarr,omitempty"      toml:"readarr"      xml:"readarr"      yaml:"readarr,omitempty"`
	Prowlarr     []StarrConfig    `json:"prowlarr,omitempty"     toml:"prowlarr"     xml:"prowlarr"     yaml:"prowlarr,omitempty"`
	Deluge       []DelugeConfig   `json:"deluge,omitempty"       toml:"deluge"       xml:"deluge"       yaml:"deluge,omitempty"`
	Qbit         []QbitConfig     `json:"qbit,omitempty"         toml:"qbit"         xml:"qbit"         yaml:"qbit,omitempty"`
	Rtorrent     []RtorrentConfig `json:"rtorrent,omitempty"     toml:"rtorrent"     xml:"rtorrent"     yaml:"rtorrent,omitempty"`
	SabNZB       []SabNZBConfig   `json:"sabnzbd,omitempty"      toml:"sabnzbd"      xml:"sabnzbd"      yaml:"sabnzbd,omitempty"`
	NZBGet       []NZBGetConfig   `json:"nzbget,omitempty"       toml:"nzbget"       xml:"nzbget"       yaml:"nzbget,omitempty"`
	Transmission []XmissionConfig `json:"transmission,omitempty" toml:"transmission" xml:"transmission" yaml:"transmission,omitempty"`
	Tautulli     TautulliConfig   `json:"tautulli"               toml:"tautulli"     xml:"tautulli"     yaml:"tautulli"`
	Plex         PlexConfig       `json:"plex"                   toml:"plex"         xml:"plex"         yaml:"plex"`
}

AppsConfig is the input configuration to relay requests to Starr apps.

type BaseConfig added in v0.9.0

type BaseConfig struct {
	APIKey  string   `json:"apiKey"    toml:"api_key"    xml:"api_key"    yaml:"apiKey"`
	ExKeys  []string `json:"extraKeys" toml:"extra_keys" xml:"extra_keys" yaml:"extraKeys"`
	URLBase string   `json:"urlbase"   toml:"urlbase"    xml:"urlbase"    yaml:"urlbase"`
	MaxBody int      `json:"maxBody"   toml:"max_body"   xml:"max_body"   yaml:"maxBody"`
	Serial  bool     `json:"serial"    toml:"serial"     xml:"serial"     yaml:"serial"`
}

type Deluge added in v0.9.0

type Deluge struct {
	DelugeConfig
	*deluge.Deluge `json:"-" toml:"-" xml:"-"`
}

func (*Deluge) Enabled added in v0.9.0

func (c *Deluge) Enabled() bool

Enabled returns true if the instance is enabled and usable.

type DelugeConfig added in v0.1.13

type DelugeConfig struct {
	ExtraConfig
	deluge.Config
}

type ExtraConfig added in v0.5.2

type ExtraConfig struct {
	Name     string        `json:"name"     toml:"name"      xml:"name"`
	Timeout  cnfg.Duration `json:"timeout"  toml:"timeout"   xml:"timeout"`
	Interval cnfg.Duration `json:"interval" toml:"interval"  xml:"interval"`
	ValidSSL bool          `json:"validSsl" toml:"valid_ssl" xml:"valid_ssl"`
	Deletes  int           `json:"deletes"  toml:"deletes"   xml:"deletes"`
}

type Lidarr

type Lidarr struct {
	StarrApp       `json:"-" toml:"-" xml:"-"`
	*lidarr.Lidarr `json:"-" toml:"-" xml:"-"`
}

Lidarr represents the input data for a Lidarr server.

type LoggingRoundTripper added in v0.4.1

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

LoggingRoundTripper allows us to use a data counter to log http request data.

func NewMetricsRoundTripper added in v0.4.1

func NewMetricsRoundTripper(app string, next http.RoundTripper) *LoggingRoundTripper

NewMetricsRoundTripper returns a round tripper to log requests counts and response sizes.

func (*LoggingRoundTripper) RoundTrip added in v0.4.1

func (rt *LoggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip satisfies the http.RoundTripper interface. This is where our logging takes place.

type NZBGet added in v0.9.0

type NZBGet struct {
	NZBGetConfig
	*nzbget.NZBGet `json:"-" toml:"-" xml:"-"`
}

func (NZBGet) Enabled added in v0.9.0

func (n NZBGet) Enabled() bool

Enabled returns true if the instance is enabled and usable.

type NZBGetConfig added in v0.3.2

type NZBGetConfig struct {
	ExtraConfig
	nzbget.Config
}

func (*NZBGetConfig) Setup added in v0.9.0

func (n *NZBGetConfig) Setup(maxBody int) *nzbget.NZBGet

type Plex added in v0.9.0

type Plex struct {
	PlexConfig
	plex.Server `json:"-" toml:"-" xml:"-"`
}

type PlexConfig added in v0.4.1

type PlexConfig struct {
	plex.Config
	ExtraConfig
}

func (*PlexConfig) Enabled added in v0.4.1

func (c *PlexConfig) Enabled() bool

Enabled returns true if the server is configured, false otherwise.

func (*PlexConfig) Setup added in v0.4.1

func (c *PlexConfig) Setup(maxBody int) Plex

type Prowlarr added in v0.9.0

type Prowlarr struct {
	StarrApp           `json:"-" toml:"-" xml:"-"`
	*prowlarr.Prowlarr `json:"-" toml:"-" xml:"-"`
}

type Qbit added in v0.9.0

type Qbit struct {
	QbitConfig
	*qbit.Qbit `json:"-" toml:"-" xml:"-"`
}

func (*Qbit) Enabled added in v0.9.0

func (q *Qbit) Enabled() bool

Enabled returns true if the instance is enabled and usable.

type QbitConfig added in v0.1.13

type QbitConfig struct {
	ExtraConfig
	qbit.Config
}

func (*QbitConfig) Setup added in v0.4.1

func (q *QbitConfig) Setup(maxBody int) (*qbit.Qbit, error)

type Radarr

type Radarr struct {
	StarrApp       `json:"-" toml:"-" xml:"-"`
	*radarr.Radarr `json:"-" toml:"-" xml:"-"`
}

type Readarr

type Readarr struct {
	StarrApp         `json:"-" toml:"-" xml:"-"`
	*readarr.Readarr `json:"-" toml:"-" xml:"-"`
}

type Rtorrent added in v0.9.0

type Rtorrent struct {
	RtorrentConfig
	*xmlrpc.Client `json:"-" toml:"-" xml:"-"`
}

func (Rtorrent) Enabled added in v0.9.0

func (r Rtorrent) Enabled() bool

Enabled returns true if the instance is enabled and usable.

type RtorrentConfig added in v0.3.2

type RtorrentConfig struct {
	ExtraConfig
	URL  string `json:"url"      toml:"url"  xml:"url"`
	User string `json:"username" toml:"user" xml:"user"`
	Pass string `json:"password" toml:"pass" xml:"pass"`
}

func (*RtorrentConfig) Setup added in v0.3.2

func (r *RtorrentConfig) Setup(maxBody int) *xmlrpc.Client

type SabNZB added in v0.9.0

type SabNZB struct {
	SabNZBConfig
	*sabnzbd.SabNZB `json:"-" toml:"-" xml:"-"`
}

type SabNZBConfig added in v0.2.0

type SabNZBConfig struct {
	ExtraConfig
	*sabnzbd.Config
}

func (*SabNZBConfig) Enabled added in v0.4.1

func (c *SabNZBConfig) Enabled() bool

Enabled returns true if the instance is enabled and usable.

func (*SabNZBConfig) Setup added in v0.4.1

func (c *SabNZBConfig) Setup(maxBody, index int) (*SabNZB, error)

type SeriesSearchItem added in v0.9.0

type SeriesSearchItem struct {
	ID                int64     `json:"id"`
	Title             string    `json:"title"`
	First             time.Time `json:"first"`
	Next              time.Time `json:"next"`
	Previous          time.Time `json:"prev"`
	Added             time.Time `json:"added"`
	Status            string    `json:"status"`
	Path              string    `json:"path"`
	TvDBID            int64     `json:"tvdbId"`
	Monitored         bool      `json:"monitored"`
	QualityProfileID  int64     `json:"qualityId"`
	SeasonFolder      bool      `json:"seasonFolder"`
	SeriesType        string    `json:"seriesType"`
	LanguageProfileID int64     `json:"languageProfileId"`
	Exists            bool      `json:"exists"`
	Year              int       `json:"year"`
	Score             int       `json:"score"`
}

type Sonarr

type Sonarr struct {
	StarrApp       `json:"-" toml:"-" xml:"-"`
	*sonarr.Sonarr `json:"-" toml:"-" xml:"-"`
}

type StarrApp added in v0.9.0

type StarrApp struct {
	StarrConfig
	// contains filtered or unexported fields
}

func (StarrApp) DelOK added in v0.9.0

func (e StarrApp) DelOK() bool

DelOK returns true if the delete limit isn't reached.

type StarrConfig added in v0.9.0

type StarrConfig struct {
	starr.Config
	ExtraConfig
}

func (StarrConfig) Enabled added in v0.9.0

func (s StarrConfig) Enabled() bool

Enabled returns true if the Sonarr instance is enabled and usable.

type Tautulli added in v0.9.0

type Tautulli struct {
	TautulliConfig
	*tautulli.Tautulli `json:"-" toml:"-" xml:"-"`
}

type TautulliConfig added in v0.2.0

type TautulliConfig struct {
	ExtraConfig
	tautulli.Config
}

func (*TautulliConfig) Enabled added in v0.4.1

func (c *TautulliConfig) Enabled() bool

Enabled returns true if the instance is enabled and usable.

func (*TautulliConfig) Setup added in v0.4.1

func (c *TautulliConfig) Setup(maxBody int) Tautulli

type Xmission added in v0.9.0

type Xmission struct {
	XmissionConfig
	*transmissionrpc.Client `json:"-" toml:"-" xml:"-"`
}

type XmissionConfig added in v0.7.0

type XmissionConfig struct {
	URL  string `json:"url"      toml:"url"  xml:"url"`
	User string `json:"username" toml:"user" xml:"user"`
	Pass string `json:"password" toml:"pass" xml:"pass"`
	ExtraConfig
}

XmissionConfig is the Transmission input configuration.

func (XmissionConfig) Enabled added in v0.7.0

func (x XmissionConfig) Enabled() bool

Enabled returns true if the instance is enabled and usable.

Directories

Path Synopsis
apppkg
plex
Package plex provides the methods the Notifiarr client uses to interface with Plex.
Package plex provides the methods the Notifiarr client uses to interface with Plex.

Jump to

Keyboard shortcuts

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