plex

package
v0.0.0-...-17bc277 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	Execute(logger log.Logger, payload WebhookPayload) error
}

Action represents a type of thing to be done for a webhook payload

type Activity

type Activity struct {
	ReceivedAt time.Time      `json:"receivedAt"`
	RequestID  string         `json:"requestId"`
	Payload    WebhookPayload `json:"payload"`
	ThumbPath  string         `json:"thumbPath,omitempty"`
}

type Config

type Config struct {
	Triggers []Trigger `json:"triggers"`
}

Config represents a plexus config

func NewConfig

func NewConfig(r io.Reader) (Config, error)

NewConfig returns an instance of config loaded from the given io.Reader

func (Config) Handle

func (c Config) Handle(logger log.Logger, pl WebhookPayload, raw []byte) error

Handle uses the current configuration to transact the given webhookpayload

type RawAction

type RawAction struct {
	Type   string                 `json:"type"`
	Config map[string]interface{} `json:"config"`
}

RawAction is the definition of a thing that should occur when a Trigger matches a Plex webhook

type Store

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

Store is used to read/write data relevant to the application. I acknowledge that this may be an unnecessary abstraction.

func NewStore

func NewStore(dbPath string) (*Store, error)

NewStore creates a JSON store instance

func (*Store) AddActivity

func (s *Store) AddActivity(act Activity) error

AddActivity appends the given Activity to the Store.

func (*Store) AddThumb

func (s *Store) AddThumb(reqID string, origFilename string, thumb []byte) (string, error)

AddThumb saves the given thumb bytes into the Store

func (*Store) GetAllActivity

func (s *Store) GetAllActivity() ([]Activity, error)

GetAllActivity returns all Activity items in the Store

type Trigger

type Trigger struct {
	Properties    map[string]interface{} `json:"properties"`
	RawActions    []RawAction            `json:"actions"`
	ParsedActions []Action               `json:"-"`
}

Trigger is a configuration for tying a specific Plex webhook to a set of desired actions

func (Trigger) IsMatch

func (t Trigger) IsMatch(payload []byte) bool

IsMatch determines if the Trigger matches the given webhook payload

type WebhookAction

type WebhookAction struct {
	URL    string
	Action string
}

func (WebhookAction) Execute

func (w WebhookAction) Execute(logger log.Logger, payload WebhookPayload) error

type WebhookPayload

type WebhookPayload struct {
	Event   string `json:"event"`
	User    bool   `json:"user"`
	Owner   bool   `json:"owner"`
	Account struct {
		ID    int    `json:"id"`
		Thumb string `json:"thumb"`
		Title string `json:"title"`
	} `json:"Account"`
	Server struct {
		Title string `json:"title"`
		UUID  string `json:"uuid"`
	} `json:"Server"`
	Player struct {
		Local         bool   `json:"local"`
		PublicAddress string `json:"publicAddress"`
		Title         string `json:"title"`
		UUID          string `json:"uuid"`
	} `json:"Player"`
	Metadata struct {
		LibrarySectionType   string `json:"librarySectionType"`
		RatingKey            string `json:"ratingKey"`
		Key                  string `json:"key"`
		ParentRatingKey      string `json:"parentRatingKey"`
		GrandparentRatingKey string `json:"grandparentRatingKey"`
		GUID                 string `json:"guid"`
		LibrarySectionID     int    `json:"librarySectionID"`
		Type                 string `json:"type"`
		Title                string `json:"title"`
		GrandparentKey       string `json:"grandparentKey"`
		ParentKey            string `json:"parentKey"`
		GrandparentTitle     string `json:"grandparentTitle"`
		ParentTitle          string `json:"parentTitle"`
		Summary              string `json:"summary"`
		Index                int    `json:"index"`
		ParentIndex          int    `json:"parentIndex"`
		RatingCount          int    `json:"ratingCount"`
		Thumb                string `json:"thumb"`
		Art                  string `json:"art"`
		ParentThumb          string `json:"parentThumb"`
		GrandparentThumb     string `json:"grandparentThumb"`
		GrandparentArt       string `json:"grandparentArt"`
		AddedAt              int    `json:"addedAt"`
		UpdatedAt            int    `json:"updatedAt"`
	} `json:"Metadata"`
}

WebhookPayload represents a payload from a plex webhook

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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