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 ¶
- Variables
- func GetURLInto(ctx context.Context, app string, timeout time.Duration, ssl bool, url string, ...) error
- type APIHandler
- type Apps
- func (a *Apps) CheckAPIKey(next http.Handler) http.HandlerFunc
- func (a *Apps) HandleAPIpath(app starr.App, uri string, api APIHandler, method ...string) *mux.Route
- func (a *Apps) InitHandlers()
- func (a *Apps) Respond(w http.ResponseWriter, stat int, msg interface{}) int64
- func (a *Apps) Setup(timeout time.Duration) error
- type DelugeConfig
- type History
- type HistorySlots
- type LidarrConfig
- type Logger
- type NZBGetConfig
- type ProwlarrConfig
- type QbitConfig
- type Queue
- type QueueSlots
- type RadarrConfig
- type ReadarrConfig
- type RtorrentConfig
- type SabNZBConfig
- type SabNZBDate
- type SabNZBSize
- type SonarrConfig
- type StageLog
- type TautulliConfig
- type TautulliUser
- type TautulliUsers
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoTMDB = fmt.Errorf("TMDB ID must not be empty") ErrNoGRID = fmt.Errorf("GRID ID must not be empty") ErrNoTVDB = fmt.Errorf("TVDB ID must not be empty") ErrNoMBID = fmt.Errorf("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) ErrNotFound = fmt.Errorf("the request returned an empty payload") ErrNonZeroID = fmt.Errorf("provided ID must be non-zero") // ErrWrongCount is returned when an app returns the wrong item count. ErrWrongCount = fmt.Errorf("wrong item count returned") ErrInvalidApp = fmt.Errorf("invalid application configuration provided") )
Errors sent to client web requests.
var ErrUnknownByteType = fmt.Errorf("unknown byte type")
Functions ¶
Types ¶
type APIHandler ¶
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 Apps ¶
type Apps 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"` Sonarr []*SonarrConfig `json:"sonarr,omitempty" toml:"sonarr" xml:"sonarr" yaml:"sonarr,omitempty"` Radarr []*RadarrConfig `json:"radarr,omitempty" toml:"radarr" xml:"radarr" yaml:"radarr,omitempty"` Lidarr []*LidarrConfig `json:"lidarr,omitempty" toml:"lidarr" xml:"lidarr" yaml:"lidarr,omitempty"` Readarr []*ReadarrConfig `json:"readarr,omitempty" toml:"readarr" xml:"readarr" yaml:"readarr,omitempty"` Prowlarr []*ProwlarrConfig `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"` Tautulli *TautulliConfig `json:"tautulli,omitempty" toml:"tautulli" xml:"tautulli" yaml:"tautulli,omitempty"` Router *mux.Router `json:"-" toml:"-" xml:"-" yaml:"-"` Logger `toml:"-" xml:"-" json:"-"` // contains filtered or unexported fields }
Apps is the input configuration to relay requests to Starr apps.
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.
type DelugeConfig ¶ added in v0.1.13
type DelugeConfig struct { *deluge.Config Name string `toml:"name" xml:"name" json:"name"` Interval cnfg.Duration `toml:"interval" xml:"interval" json:"interval"` Timeout cnfg.Duration `toml:"timeout" xml:"timeout" json:"timeout"` VerifySSL bool `toml:"verify_ssl" xml:"verify_ssl" json:"verifySsl"` *deluge.Deluge `toml:"-" xml:"-" json:"-"` }
type History ¶ added in v0.2.0
type History struct { TotalSize SabNZBSize `json:"total_size"` MonthSize SabNZBSize `json:"month_size"` WeekSize SabNZBSize `json:"week_size"` DaySize SabNZBSize `json:"day_size"` Slots []HistorySlots `json:"slots"` Noofslots int `json:"noofslots"` LastHistoryUpdate int64 `json:"last_history_update"` Version string `json:"version"` }
type HistorySlots ¶ added in v0.2.0
type HistorySlots struct { ID int64 `json:"id"` Completed int64 `json:"completed"` Name string `json:"name"` NzbName string `json:"nzb_name"` Category string `json:"category"` Pp string `json:"pp"` Script string `json:"script"` Report string `json:"report"` URL string `json:"url"` Status string `json:"status"` NzoID string `json:"nzo_id"` Storage string `json:"storage"` Path string `json:"path"` ScriptLog string `json:"script_log"` ScriptLine string `json:"script_line"` DownloadTime int64 `json:"download_time"` PostprocTime int64 `json:"postproc_time"` StageLog []*StageLog `json:"stage_log"` Downloaded int64 `json:"downloaded"` Completeness interface{} `json:"completeness"` FailMessage string `json:"fail_message"` URLInfo string `json:"url_info"` Bytes int64 `json:"bytes"` Meta interface{} `json:"meta"` Series string `json:"series"` Md5Sum string `json:"md5sum"` Password string `json:"password"` ActionLine string `json:"action_line"` Size string `json:"size"` Loaded bool `json:"loaded"` Retry int `json:"retry"` }
HistorySlots is part of the json response from SABnzbd.
type LidarrConfig ¶
type LidarrConfig struct { *starr.Config *lidarr.Lidarr `toml:"-" xml:"-" json:"-"` // contains filtered or unexported fields }
LidarrConfig represents the input data for a Lidarr server.
type NZBGetConfig ¶ added in v0.3.2
type NZBGetConfig struct { *nzbget.Config Name string `toml:"name" xml:"name" json:"name"` Interval cnfg.Duration `toml:"interval" xml:"interval" json:"interval"` Timeout cnfg.Duration `toml:"timeout" xml:"timeout" json:"timeout"` VerifySSL bool `toml:"verify_ssl" xml:"verify_ssl" json:"verifySsl"` *nzbget.NZBGet `toml:"-" xml:"-" json:"-"` }
type ProwlarrConfig ¶ added in v0.2.5
type ProwlarrConfig struct { *starr.Config *prowlarr.Prowlarr `toml:"-" xml:"-" json:"-"` // contains filtered or unexported fields }
ProwlarrConfig represents the input data for a Prowlarr server.
type QbitConfig ¶ added in v0.1.13
type QbitConfig struct { *qbit.Config Name string `toml:"name" xml:"name" json:"name"` Interval cnfg.Duration `toml:"interval" xml:"interval" json:"interval"` Timeout cnfg.Duration `toml:"timeout" xml:"timeout" json:"timeout"` VerifySSL bool `toml:"verify_ssl" xml:"verify_ssl" json:"verifySsl"` *qbit.Qbit `toml:"-" xml:"-" json:"-"` }
type Queue ¶ added in v0.2.0
type Queue struct { Version string `json:"version"` PauseInt string `json:"pause_int"` Diskspace1 float64 `json:"diskspace1,string"` Diskspace2 float64 `json:"diskspace2,string"` Diskspace1Norm SabNZBSize `json:"diskspace1_norm"` Diskspace2Norm SabNZBSize `json:"diskspace2_norm"` Diskspacetotal1 float64 `json:"diskspacetotal1,string"` Diskspacetotal2 float64 `json:"diskspacetotal2,string"` Loadavg string `json:"loadavg"` Speedlimit float64 `json:"speedlimit,string"` SpeedlimitAbs string `json:"speedlimit_abs"` HaveWarnings string `json:"have_warnings"` Finishaction interface{} `json:"finishaction"` Quota string `json:"quota"` LeftQuota string `json:"left_quota"` CacheArt string `json:"cache_art"` CacheSize SabNZBSize `json:"cache_size"` CacheMax int64 `json:"cache_max,string"` Kbpersec float64 `json:"kbpersec,string"` Speed SabNZBSize `json:"speed"` Mbleft float64 `json:"mbleft,string"` Mb float64 `json:"mb,string"` Sizeleft SabNZBSize `json:"sizeleft"` Size SabNZBSize `json:"size"` NoofslotsTotal int `json:"noofslots_total"` Status string `json:"status"` Timeleft string `json:"timeleft"` Eta string `json:"eta"` RefreshRate string `json:"refresh_rate"` InterfaceSettings string `json:"interface_settings"` Scripts []string `json:"scripts"` Categories []string `json:"categories"` Noofslots int `json:"noofslots"` Start int64 `json:"start"` Limit int64 `json:"limit"` Finish int64 `json:"finish"` Slots []QueueSlots `json:"slots"` PausedAll bool `json:"paused_all"` RatingEnable bool `json:"rating_enable"` Paused bool `json:"paused"` HaveQuota bool `json:"have_quota"` }
type QueueSlots ¶ added in v0.2.0
type QueueSlots struct { Status string `json:"status"` Index int `json:"index"` Password string `json:"password"` AvgAge string `json:"avg_age"` Script string `json:"script"` HasRating bool `json:"has_rating"` Mb string `json:"mb"` Mbleft float64 `json:"mbleft,string"` Mbmissing float64 `json:"mbmissing,string"` Size SabNZBSize `json:"size"` Sizeleft SabNZBSize `json:"sizeleft"` Filename string `json:"filename"` Labels []string `json:"labels"` Priority string `json:"priority"` Cat string `json:"cat"` Eta SabNZBDate `json:"eta"` Timeleft string `json:"timeleft"` Percentage int `json:"percentage,string"` NzoID string `json:"nzo_id"` Unpackopts string `json:"unpackopts"` }
QueueSlots has the following data structure.
{ "index": 1, "nzo_id": "SABnzbd_nzo_xnfbbdbh", "unpackopts": "3", "priority": "Normal", "script": "wtfnzb-renamer.py", "filename": "Rick Astley - Never Gonna Give You Up (1987)(24bit flac vinyl)", "labels": [], "password": "", "cat": "prowlarr", "mbleft": "593.67", "mb": "701.34", "size": "701.3 MB", "sizeleft": "593.7 MB", "percentage": "15", "mbmissing": "0.00", "direct_unpack": 0, "status": "Downloading", "timeleft": "0:03:57", "eta": "13:42 Sun 17 Oct", "avg_age": "2537d", "has_rating": false }
Payload for this structure.
type RadarrConfig ¶
type RadarrConfig struct { *starr.Config *radarr.Radarr `toml:"-" xml:"-" json:"-"` // contains filtered or unexported fields }
RadarrConfig represents the input data for a Radarr server.
type ReadarrConfig ¶
type ReadarrConfig struct { *starr.Config *readarr.Readarr `toml:"-" xml:"-" json:"-"` // contains filtered or unexported fields }
ReadarrConfig represents the input data for a Readarr server.
type RtorrentConfig ¶ added in v0.3.2
type RtorrentConfig struct { *xmlrpc.Client Name string `toml:"name" xml:"name" json:"name"` URL string `toml:"url" xml:"url" json:"url"` User string `toml:"user" xml:"user" json:"user"` Pass string `toml:"pass" xml:"pass" json:"pass"` Interval cnfg.Duration `toml:"interval" xml:"interval" json:"interval"` Timeout cnfg.Duration `toml:"timeout" xml:"timeout" json:"timeout"` VerifySSL bool `toml:"verify_ssl" xml:"verify_ssl" json:"verifySsl"` }
func (*RtorrentConfig) Setup ¶ added in v0.3.2
func (r *RtorrentConfig) Setup(timeout time.Duration)
type SabNZBConfig ¶ added in v0.2.0
type SabNZBConfig struct { Name string `toml:"name" xml:"name"` Interval cnfg.Duration `toml:"interval" xml:"interval"` Timeout cnfg.Duration `toml:"timeout" xml:"timeout"` URL string `toml:"url" xml:"url"` APIKey string `toml:"api_key" xml:"api_key"` VerifySSL bool `toml:"verify_ssl" xml:"verify_ssl"` }
func (*SabNZBConfig) GetHistory ¶ added in v0.2.0
func (s *SabNZBConfig) GetHistory(ctx context.Context) (*History, error)
GetHistory returns the history items in SABnzbd.
type SabNZBDate ¶ added in v0.2.0
SabNZBDate is used to parse a custm date format from the json api.
func (*SabNZBDate) UnmarshalJSON ¶ added in v0.2.0
func (s *SabNZBDate) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON exists because weird date formats and "unknown" seem sane in json output.
type SabNZBSize ¶ added in v0.2.0
SabNZBSize deals with bytes encoded as strings.
func (*SabNZBSize) UnmarshalJSON ¶ added in v0.2.0
func (s *SabNZBSize) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON exists because someone decided that bytes should be strings with letters.
type SonarrConfig ¶
type SonarrConfig struct { *sonarr.Sonarr `toml:"-" xml:"-" json:"-"` *starr.Config // contains filtered or unexported fields }
SonarrConfig represents the input data for a Sonarr server.
type TautulliConfig ¶ added in v0.2.0
type TautulliConfig struct { Name string `toml:"name" xml:"name" json:"name"` Interval cnfg.Duration `toml:"interval" xml:"interval" json:"interval"` Timeout cnfg.Duration `toml:"timeout" xml:"timeout" json:"timeout"` URL string `toml:"url" xml:"url" json:"url"` APIKey string `toml:"api_key" xml:"api_key" json:"apiKey"` VerifySSL bool `toml:"verify_ssl" xml:"verify_ssl" json:"verifySsl"` }
func (*TautulliConfig) GetUsers ¶ added in v0.2.0
func (t *TautulliConfig) GetUsers(ctx context.Context) (*TautulliUsers, error)
GetUsers returns the Tautulli users.
type TautulliUser ¶ added in v0.2.0
type TautulliUser struct { RowID int64 `json:"row_id"` UserID int64 `json:"user_id"` Username string `json:"username"` FriendlyName string `json:"friendly_name"` Thumb string `json:"thumb"` Email string `json:"email"` ServerToken string `json:"server_token"` FilterAll string `json:"filter_all"` FilterMovies string `json:"filter_movies"` FilterTv string `json:"filter_tv"` FilterMusic string `json:"filter_music"` FilterPhotos string `json:"filter_photos"` IsActive int `json:"is_active"` // 1,0 (bool) IsAdmin int `json:"is_admin"` // 1,0 (bool) IsHomeUser int `json:"is_home_user"` // 1,0 (bool) IsAllowSync int `json:"is_allow_sync"` // 1,0 (bool) IsRestricted int `json:"is_restricted"` // 1,0 (bool) DoNotify int `json:"do_notify"` // 1,0 (bool) KeepHistory int `json:"keep_history"` // 1,0 (bool) AllowGuest int `json:"allow_guest"` // 1,0 (bool) }
TautulliUser is the user data from the get_users API call.
type TautulliUsers ¶ added in v0.2.0
type TautulliUsers struct { Response struct { Result string `json:"result"` // success, error Message string `json:"message"` // error msg Data []TautulliUser `json:"data"` } `json:"response"` }
TautulliUsers is the entire get_users API response.
func (*TautulliUsers) MapEmailName ¶ added in v0.2.0
func (t *TautulliUsers) MapEmailName() map[string]string
MapEmailName returns a map of email => name for Tautulli users.