Documentation ¶
Overview ¶
Package notifiarr provides a standard interface for sending data to notifiarr.com. Several methods are exported to make POSTing data to notifarr easier. This package also handles the "crontab" timers for plex sessions, snapshots, custom format sync for Radarr and release profile sync for Sonarr. This package's cofiguration is provided by the configfile package.
Index ¶
- Constants
- Variables
- type ClientInfo
- type Config
- func (c *Config) GetClientInfo() (*ClientInfo, error)
- func (c *Config) GetMetaSnap(ctx context.Context) *snapshot.Snapshot
- func (c *Config) SendData(url string, payload interface{}, pretty bool) (*http.Response, []byte, error)
- func (c *Config) SendFinishedQueueItems(url string)
- func (c *Config) SendJSON(url string, data []byte) (*http.Response, []byte, error)
- func (c *Config) SendMeta(eventType, url string, hook *plex.Webhook, wait time.Duration) ([]byte, error)
- func (c *Config) Start(mode string)
- func (c *Config) Stop()
- func (c *Config) SyncCF(wait bool)
- type ItemList
- type Payload
- type QueuePayload
- type RadarrCustomFormatPayload
- type SonarrCustomFormatPayload
Constants ¶
const ( BaseURL = "https://notifiarr.com" ProdURL = BaseURL + "/notifier.php" TestURL = BaseURL + "/notifierTest.php" DevBaseURL = "http://dev.notifiarr.com" DevURL = DevBaseURL + "/notifier.php" ClientRoute = "/api/v1/user/client" // CFSyncRoute is the webserver route to send sync requests to. CFSyncRoute = "/api/v1/user/trash" )
Notifiarr URLs.
const ( PlexCron = "plexcron" SnapCron = "snapcron" PlexHook = "plexhook" LogLocal = "loglocal" )
These are used as 'source' values in json payloads sent to the webserver.
const ( // DefaultRetries is the number of times to attempt a request to notifiarr.com. // 4 means 5 total tries: 1 try + 4 retries. DefaultRetries = 4 // RetryDelay is how long to Sleep between retries. RetryDelay = 222 * time.Millisecond )
Variables ¶
var ( ErrNon200 = fmt.Errorf("return code was not 200") ErrInvalidResponse = fmt.Errorf("invalid response") )
Errors returned by this library.
Functions ¶
This section is empty.
Types ¶
type ClientInfo ¶ added in v0.1.6
type ClientInfo struct { Status string `json:"status"` Message struct { Text string `json:"text"` Subscriber bool `json:"subscriber"` CFSync int64 `json:"cfSync"` RPSync int64 `json:"rpSync"` } `json:"message"` }
ClientInfo is the reply from the ClienRoute endpoint.
func (*ClientInfo) IsASub ¶ added in v0.1.6
func (c *ClientInfo) IsASub() bool
IsASub returns true if the client is a subscriber. False otherwise.
func (*ClientInfo) String ¶ added in v0.1.6
func (c *ClientInfo) String() string
String returns the message text for a client info response.
type Config ¶
type Config struct { Apps *apps.Apps // has API key Plex *plex.Server // plex sessions Snap *snapshot.Config // system snapshot data Retries int URL string BaseURL string Timeout time.Duration ClientInfo *ClientInfo *logs.Logger // log file writer // contains filtered or unexported fields }
Config is the input data needed to send payloads to notifiarr.
func (*Config) GetClientInfo ¶ added in v0.1.6
func (c *Config) GetClientInfo() (*ClientInfo, error)
GetClientInfo returns an error if the API key is wrong. Returns client info otherwise.
func (*Config) GetMetaSnap ¶
GetMetaSnap grabs some basic system info: cpu, memory, username.
func (*Config) SendData ¶
func (c *Config) SendData(url string, payload interface{}, pretty bool) (*http.Response, []byte, error)
SendData sends raw data to a notifiarr URL as JSON.
func (*Config) SendFinishedQueueItems ¶ added in v0.1.9
func (*Config) SendJSON ¶
SendJSON posts a JSON payload to a URL. Returns the response body or an error.
func (*Config) SendMeta ¶
func (c *Config) SendMeta(eventType, url string, hook *plex.Webhook, wait time.Duration) ([]byte, error)
SendMeta is kicked off by the webserver in go routine. It's also called by the plex cron (with webhook set to nil). This runs after Plex drops off a webhook telling us someone did something. This gathers cpu/ram, and waits 10 seconds, then grabs plex sessions. It's all POSTed to notifiarr. May be used with a nil Webhook.
type Payload ¶
type Payload struct { Type string `json:"eventType"` Plex *plex.Sessions `json:"plex,omitempty"` Snap *snapshot.Snapshot `json:"snapshot,omitempty"` Load *plex.Webhook `json:"payload,omitempty"` }
Payload is the outbound payload structure that is sent to Notifiarr for Plex and system snapshot data.
type QueuePayload ¶ added in v0.1.9
type RadarrCustomFormatPayload ¶ added in v0.1.6
type RadarrCustomFormatPayload struct { Instance int `json:"instance"` CustomFormats []*radarr.CustomFormat `json:"customFormats,omitempty"` QualityProfiles []*radarr.QualityProfile `json:"qualityProfiles,omitempty"` NewMaps *cfMapIDpayload `json:"newMaps,omitempty"` }
RadarrCustomFormatPayload is the payload sent and received to/from notifarr.com when updating custom formats for Radarr.
type SonarrCustomFormatPayload ¶ added in v0.1.6
type SonarrCustomFormatPayload struct { Instance int `json:"instance"` ReleaseProfiles []*sonarr.ReleaseProfile `json:"releaseProfiles,omitempty"` QualityProfiles []*sonarr.QualityProfile `json:"qualityProfiles,omitempty"` NewMaps *cfMapIDpayload `json:"newMaps,omitempty"` }
SonarrCustomFormatPayload is the payload sent and received to/from notifarr.com when updating custom formats for Sonarr.