plex

package module
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 19 Imported by: 4

README

Plex.tv and Plex Media Server client written in Go

godoc

go get -u github.com/jrudio/go-plex-client

Cli

You can tinker with this library using the command-line over here

Usage
plexConnection, err := plex.New("http://192.168.1.2:32400", "myPlexToken")

// Test your connection to your Plex server
result, err := plexConnection.Test()

// Search for media in your plex server
results, err := plexConnection.Search("The Walking Dead")

// Webhook handler to easily handle events on your server
	wh := plex.NewWebhook()

	wh.OnPlay(func(w plex.Webhook) {
		fmt.Printf("%s is playing\n", w.Metadata.Title)
	})

	wh.OnPause(func(w plex.Webhook) {
		fmt.Printf("%s is paused\n", w.Metadata.Title)
	})

	wh.OnResume(func(w plex.Webhook) {
		fmt.Printf("%s has resumed\n", w.Metadata.Title)
	})

	wh.OnStop(func(w plex.Webhook) {
		fmt.Printf("%s has stopped\n", w.Metadata.Title)
	})

	http.HandleFunc("/", wh.Handler)

	http.ListenAndServe("192.168.1.14:8080", nil)

// connect to your server via websockets to listen for events

ctrlC := make(chan os.Signal, 1)
onError := func(err error) {
	fmt.Println(err)
}

events := plex.NewNotificationEvents()
events.OnPlaying(func(n NotificationContainer) {
	mediaID := n.PlaySessionStateNotification[0].RatingKey
	sessionID := n.PlaySessionStateNotification[0].SessionKey
	var title

	sessions, err := plexConnection.GetSessions()

	if err != nil {
		fmt.Printf("failed to fetch sessions on plex server: %v\n", err)
		return
	}

	for _, session := range sessions.MediaContainer.Video {
		if sessionID != session.SessionKey {
			continue
		}

		userID = session.User.ID
		username = session.User.Title

		break
	}

	metadata, err := plexConnection.GetMetadata(mediaID)

	if err != nil {
		fmt.Printf("failed to get metadata for key %s: %v\n", mediaID, err)
	} else {
		title = metadata.MediaContainer.Metadata[0].Title
	}

	fmt.Printf("user (id: %s) has started playing %s (id: %s) %s\n", username, userID, title, mediaID)
})

plexConnection.SubscribeToNotifications(events, ctrlC, onError)

// ... and more! Please checkout plex.go for more methods

Documentation

Index

Constants

View Source
const (
	ErrorInvalidToken       = "invalid token"
	ErrorNotAuthorized      = "you are not authorized to access that server"
	ErrorCommon             = "error: %s"
	ErrorKeyIsRequired      = "key is required"
	ErrorTitleRequired      = "a title is required"
	ErrorServerReplied      = "server replied with %d status code"
	ErrorMissingSessionKey  = "missing sessionKey"
	ErrorUrlTokenRequired   = "url or a token is required"
	ErrorServer             = "server error: %s"
	ErrorPINNotAuthorized   = "pin is not authorized yet"
	ErrorLinkAccount        = "failed to link account: %s"
	ErrorFailedToSetWebhook = "failed to set webhook"
)

ErrorInvalidToken a constant to help check invalid token errors

Variables

This section is empty.

Functions

func GetMediaType

func GetMediaType(info MediaMetadata) string

GetMediaType is a helper function that returns the media type. Usually, used after GetMetadata().

func GetMediaTypeID

func GetMediaTypeID(mediaType string) string

GetMediaTypeID returns plex's media type id

Types

type ActivityNotification

type ActivityNotification struct {
	Activity struct {
		Cancellable bool   `json:"cancellable"`
		Progress    int64  `json:"progress"`
		Subtitle    string `json:"subtitle"`
		Title       string `json:"title"`
		Type        string `json:"type"`
		UserID      int64  `json:"userID"`
		UUID        string `json:"uuid"`
	} `json:"Activity"`
	Event string `json:"event"`
	UUID  string `json:"uuid"`
}

ActivityNotification ...

type AltGUID added in v1.0.3

type AltGUID struct {
	ID string `json:"id"`
}

AltGUID represents a Globally Unique Identifier for a metadata provider that is not actively being used.

type BackgroundProcessingQueueEventNotification

type BackgroundProcessingQueueEventNotification struct {
	Event   string `json:"event"`
	QueueID int64  `json:"queueID"`
}

BackgroundProcessingQueueEventNotification ...

type BaseAPIResponse

type BaseAPIResponse struct {
	MediaContainer struct {
		Directory []struct {
			Count int64  `json:"count"`
			Key   string `json:"key"`
			Title string `json:"title"`
		} `json:"Directory"`
		AllowCameraUpload             bool   `json:"allowCameraUpload"`
		AllowChannelAccess            bool   `json:"allowChannelAccess"`
		AllowSharing                  bool   `json:"allowSharing"`
		AllowSync                     bool   `json:"allowSync"`
		BackgroundProcessing          bool   `json:"backgroundProcessing"`
		Certificate                   bool   `json:"certificate"`
		CompanionProxy                bool   `json:"companionProxy"`
		CountryCode                   string `json:"countryCode"`
		Diagnostics                   string `json:"diagnostics"`
		EventStream                   bool   `json:"eventStream"`
		FriendlyName                  string `json:"friendlyName"`
		HubSearch                     bool   `json:"hubSearch"`
		ItemClusters                  bool   `json:"itemClusters"`
		Livetv                        int64  `json:"livetv"`
		MachineIdentifier             string `json:"machineIdentifier"`
		MediaProviders                bool   `json:"mediaProviders"`
		Multiuser                     bool   `json:"multiuser"`
		MyPlex                        bool   `json:"myPlex"`
		MyPlexMappingState            string `json:"myPlexMappingState"`
		MyPlexSigninState             string `json:"myPlexSigninState"`
		MyPlexSubscription            bool   `json:"myPlexSubscription"`
		MyPlexUsername                string `json:"myPlexUsername"`
		OwnerFeatures                 string `json:"ownerFeatures"`
		PhotoAutoTag                  bool   `json:"photoAutoTag"`
		Platform                      string `json:"platform"`
		PlatformVersion               string `json:"platformVersion"`
		PluginHost                    bool   `json:"pluginHost"`
		ReadOnlyLibraries             bool   `json:"readOnlyLibraries"`
		RequestParametersInCookie     bool   `json:"requestParametersInCookie"`
		Size                          int64  `json:"size"`
		StreamingBrainABRVersion      int64  `json:"streamingBrainABRVersion"`
		StreamingBrainVersion         int64  `json:"streamingBrainVersion"`
		Sync                          bool   `json:"sync"`
		TranscoderActiveVideoSessions int64  `json:"transcoderActiveVideoSessions"`
		TranscoderAudio               bool   `json:"transcoderAudio"`
		TranscoderLyrics              bool   `json:"transcoderLyrics"`
		TranscoderPhoto               bool   `json:"transcoderPhoto"`
		TranscoderSubtitles           bool   `json:"transcoderSubtitles"`
		TranscoderVideo               bool   `json:"transcoderVideo"`
		TranscoderVideoBitrates       string `json:"transcoderVideoBitrates"`
		TranscoderVideoQualities      string `json:"transcoderVideoQualities"`
		TranscoderVideoResolutions    string `json:"transcoderVideoResolutions"`
		UpdatedAt                     int64  `json:"updatedAt"`
		Updater                       bool   `json:"updater"`
		Version                       string `json:"version"`
		VoiceSearch                   bool   `json:"voiceSearch"`
	} `json:"MediaContainer"`
}

BaseAPIResponse info about the Plex Media Server

type Connection

type Connection struct {
	Protocol string `json:"protocol" xml:"protocol,attr"`
	Address  string `json:"address" xml:"address,attr"`
	Port     string `json:"port" xml:"port,attr"`
	URI      string `json:"uri" xml:"uri,attr"`
	Local    int    `json:"local" xml:"local,attr"`
	Relay    bool   `json:"relay" xml:"relay,attr"`
}

Connection lists options to connect to a device

type CreateLibraryParams

type CreateLibraryParams struct {
	Name        string
	Location    string
	LibraryType string
	Agent       string
	Scanner     string
	Language    string
}

CreateLibraryParams params required to create a library

func LibraryParamsFromMediaType

func LibraryParamsFromMediaType(mediaType string) (CreateLibraryParams, error)

LibraryParamsFromMediaType is a helper for CreateLibraryParams

type CurrentSessions

type CurrentSessions struct {
	MediaContainer struct {
		Metadata []MetadataV1 `json:"Metadata"`
		Size     int          `json:"size"`
	} `json:"MediaContainer"`
}

CurrentSessions metadata of users consuming media

type DevicesResponse

type DevicesResponse struct {
	ID         int    `json:"id"`
	LastSeenAt string `json:"lastSeenAt"`
	Name       string `json:"name"`
	Product    string `json:"product"`
	Version    string `json:"version"`
}

DevicesResponse metadata of a device that has connected to your server

type Directory

type Directory struct {
	Location   []Location `json:"Location"`
	Agent      string     `json:"agent"`
	AllowSync  bool       `json:"allowSync"`
	Art        string     `json:"art"`
	Composite  string     `json:"composite"`
	CreatedAt  int        `json:"createdAt"`
	Filter     bool       `json:"filters"`
	Key        string     `json:"key"`
	Language   string     `json:"language"`
	Refreshing bool       `json:"refreshing"`
	Scanner    string     `json:"scanner"`
	Thumb      string     `json:"thumb"`
	Title      string     `json:"title"`
	Type       string     `json:"type"`
	UpdatedAt  int        `json:"updatedAt"`
	UUID       string     `json:"uuid"`
}

Directory shows plex directory metadata

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorResponse contains a code and an error message

type FixedRating added in v1.1.7

type FixedRating float32

func (*FixedRating) UnmarshalJSON added in v1.1.7

func (value *FixedRating) UnmarshalJSON(data []byte) error

type Friends

type Friends struct {
	ID                        int    `xml:"id,attr"`
	Title                     string `xml:"title,attr"`
	Thumb                     string `xml:"thumb,attr"`
	Protected                 string `xml:"protected,attr"`
	Home                      string `xml:"home,attr"`
	AllowSync                 string `xml:"allowSync,attr"`
	AllowCameraUpload         string `xml:"allowCameraUpload,attr"`
	AllowChannels             string `xml:"allowChannels,attr"`
	FilterAll                 string `xml:"filterAll,attr"`
	FilterMovies              string `xml:"filterMovies,attr"`
	FilterMusic               string `xml:"filterMusic,attr"`
	FilterPhotos              string `xml:"filterPhotos,attr"`
	FilterTelevision          string `xml:"filterTelevision,attr"`
	Restricted                string `xml:"restricted,attr"`
	Username                  string `xml:"username,attr"`
	Email                     string `xml:"email,attr"`
	RecommendationsPlaylistID string `xml:"recommendationsPlaylistId,attr"`
	Server                    struct {
		ID                string `xml:"id,attr"`
		ServerID          string `xml:"serverId,attr"`
		MachineIdentifier string `xml:"machineIdentifier,attr"`
		Name              string `xml:"name,attr"`
		LastSeenAt        string `xml:"lastSeenAt,attr"`
		NumLibraries      string `xml:"numLibraries,attr"`
		AllLibraries      string `xml:"allLibraries,attr"`
		Owned             string `xml:"owned,attr"`
		Pending           string `xml:"pending,attr"`
	} `xml:"Server"`
}

Friends are the plex accounts that have access to your server

type InviteFriendParams

type InviteFriendParams struct {
	UsernameOrEmail string
	MachineID       string
	Label           string
	LibraryIDs      []int
}

InviteFriendParams are the params to invite a friend

type LibraryLabels

type LibraryLabels struct {
	ElementType     string `json:"_elementType"`
	AllowSync       string `json:"allowSync"`
	Art             string `json:"art"`
	Content         string `json:"content"`
	Identifier      string `json:"identifier"`
	MediaTagPrefix  string `json:"mediaTagPrefix"`
	MediaTagVersion string `json:"mediaTagVersion"`
	Thumb           string `json:"thumb"`
	Title1          string `json:"title1"`
	Title2          string `json:"title2"`
	ViewGroup       string `json:"viewGroup"`
	ViewMode        string `json:"viewMode"`
	Children        []struct {
		ElementType string `json:"_elementType"`
		FastKey     string `json:"fastKey"`
		Key         string `json:"key"`
		Title       string `json:"title"`
	} `json:"_children"`
}

LibraryLabels are the existing labels set on your server

type LibrarySections

type LibrarySections struct {
	MediaContainer struct {
		Directory []Directory `json:"Directory"`
	} `json:"MediaContainer"`
}

LibrarySections metadata of your library contents

type Location

type Location struct {
	ID   int    `json:"id"`
	Path string `json:"path"`
}

Location is the path of a plex server directory

type Media

type Media struct {
	AspectRatio           string `json:"aspectRatio"`
	AudioChannels         int    `json:"audioChannels"`
	AudioCodec            string `json:"audioCodec"`
	AudioProfile          string `json:"audioProfile"`
	Bitrate               int    `json:"bitrate"`
	Container             string `json:"container"`
	DeletedAt             int    `json:"deletedAt"`
	Duration              int    `json:"duration"`
	Has64bitOffsets       bool   `json:"has64bitOffsets"`
	Height                int    `json:"height"`
	ID                    int    `json:"id"`
	OptimizedForStreaming int    `json:"optimizedForStreaming"`
	Selected              bool   `json:"selected"`
	VideoCodec            string `json:"videoCodec"`
	VideoFrameRate        string `json:"videoFrameRate"`
	VideoProfile          string `json:"videoProfile"`
	VideoResolution       string `json:"videoResolution"`
	Width                 int    `json:"width"`
	Part                  []Part `json:"Part"`
}

Media media info

type MediaContainer

type MediaContainer struct {
	Metadata            []Metadata `json:"Metadata"`
	AllowSync           bool       `json:"allowSync"`
	Identifier          string     `json:"identifier"`
	LibrarySectionID    int        `json:"librarySectionID"`
	LibrarySectionTitle string     `json:"librarySectionTitle"`
	LibrarySectionUUID  string     `json:"librarySectionUUID"`
	MediaTagPrefix      string     `json:"mediaTagPrefix"`
	MediaTagVersion     int        `json:"mediaTagVersion"`
	Size                int        `json:"size"`
}

MediaContainer contains media info

type MediaMetadata

type MediaMetadata struct {
	MediaContainer MediaContainer `json:"MediaContainer"`
}

MediaMetadata ...

type MediaV1

type MediaV1 struct {
	Media
	Part                  []PartV1  `json:"Part"`
	AudioChannels         int       `json:"audioChannels"`
	AspectRatio           float32   `json:"aspectRatio,string"`
	Bitrate               int       `json:"bitrate"`
	Duration              Timestamp `json:"duration"`
	Has64bitOffsets       bool      `json:"has64bitOffsets"`
	Height                int       `json:"height"`
	ID                    int       `json:"id,string"`
	OptimizedForStreaming bool      `json:"optimizedForStreaming"`
	Width                 int       `json:"width"`
}

MediaV1 media information version 1

type Metadata

type Metadata struct {
	Player                Player       `json:"Player"`
	Session               Session      `json:"Session"`
	User                  User         `json:"User"`
	AddedAt               int          `json:"addedAt"`
	Art                   string       `json:"art"`
	AudienceRating        float64      `json:"audienceRating"`
	AudienceRatingImage   string       `json:"audienceRatingImage"`
	ContentRating         string       `json:"contentRating"`
	Duration              int          `json:"duration"`
	GrandparentArt        string       `json:"grandparentArt"`
	GrandparentGUID       string       `json:"grandparentGuid"`
	GrandparentKey        string       `json:"grandparentKey"`
	GrandparentRatingKey  string       `json:"grandparentRatingKey"`
	GrandparentTheme      string       `json:"grandparentTheme"`
	GrandparentThumb      string       `json:"grandparentThumb"`
	GrandparentTitle      string       `json:"grandparentTitle"`
	GUID                  string       `json:"guid"`
	AltGUIDs              []AltGUID    `json:"Guid"`
	Index                 int64        `json:"index"`
	Key                   string       `json:"key"`
	LastViewedAt          int          `json:"lastViewedAt"`
	LibrarySectionID      int          `json:"librarySectionID"`
	LibrarySectionKey     string       `json:"librarySectionKey"`
	LibrarySectionTitle   string       `json:"librarySectionTitle"`
	Live                  string       `json:"live"`
	OriginallyAvailableAt string       `json:"originallyAvailableAt"`
	OriginalTitle         string       `json:"originalTitle"`
	ParentGUID            string       `json:"parentGuid"`
	ParentIndex           int64        `json:"parentIndex"`
	ParentKey             string       `json:"parentKey"`
	ParentRatingKey       string       `json:"parentRatingKey"`
	ParentThumb           string       `json:"parentThumb"`
	ParentTitle           string       `json:"parentTitle"`
	RatingCount           int          `json:"ratingCount"`
	Ratings               []Rating     `json:"Rating"`
	Rating                float64      `json:"rating"`
	RatingKey             string       `json:"ratingKey"`
	SessionKey            string       `json:"sessionKey"`
	Summary               string       `json:"summary"`
	Thumb                 string       `json:"thumb"`
	Media                 []Media      `json:"Media"`
	Title                 string       `json:"title"`
	TitleSort             string       `json:"titleSort"`
	Type                  string       `json:"type"`
	UpdatedAt             int          `json:"updatedAt"`
	UserRating            float64      `json:"userRating,string"`
	ViewCount             json.Number  `json:"viewCount"`
	ViewOffset            int          `json:"viewOffset"`
	Year                  int          `json:"year"`
	Director              []TaggedData `json:"Director"`
	Writer                []TaggedData `json:"Writer"`
}

Metadata ...

type MetadataChildren

type MetadataChildren struct {
	MediaContainer MediaContainer `json:"MediaContainer"`
}

MetadataChildren returns metadata about a piece of media (tv show, movie, music, etc)

type MetadataV1

type MetadataV1 struct {
	Metadata
	Index            int64     `json:"index"`
	ParentIndex      int64     `json:"parentIndex"`
	AddedAt          int64     `json:"addedAt"`
	Duration         int64     `json:"duration"`
	LastViewedAt     Timestamp `json:"lastViewedAt"`
	LibrarySectionID string    `json:"librarySectionID"`
	Media            []MediaV1 `json:"Media"`
	Rating           float64   `json:"rating"`
	UpdatedAt        Timestamp `json:"updatedAt"`
	ViewOffset       int64     `json:"viewOffset"`
	Year             int       `json:"year"`
}

MetadataV1 ...

type NotificationContainer

type NotificationContainer struct {
	TimelineEntry []TimelineEntry `json:"TimelineEntry"`

	ActivityNotification []ActivityNotification `json:"ActivityNotification"`

	StatusNotification []StatusNotification `json:"StatusNotification"`

	PlaySessionStateNotification []PlaySessionStateNotification `json:"PlaySessionStateNotification"`

	ReachabilityNotification []ReachabilityNotification `json:"ReachabilityNotification"`

	BackgroundProcessingQueueEventNotification []BackgroundProcessingQueueEventNotification `json:"BackgroundProcessingQueueEventNotification"`

	TranscodeSession []TranscodeSession `json:"TranscodeSession"`

	Setting []Setting `json:"Setting"`

	Size int64 `json:"size"`
	// Type can be one of:
	// playing,
	// reachability,
	// transcode.end,
	// preference,
	// update.statechange,
	// activity,
	// backgroundProcessingQueue,
	// transcodeSession.update
	// transcodeSession.end
	Type string `json:"type"`
}

NotificationContainer read pms notifications

type NotificationEvents

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

NotificationEvents hold callbacks that correspond to notifications

func NewNotificationEvents

func NewNotificationEvents() *NotificationEvents

NewNotificationEvents initializes the event callbacks

func (*NotificationEvents) OnPlaying

func (e *NotificationEvents) OnPlaying(fn func(n NotificationContainer))

OnPlaying shows state information (resume, stop, pause) on a user consuming media in plex

func (*NotificationEvents) OnTranscodeUpdate

func (e *NotificationEvents) OnTranscodeUpdate(fn func(n NotificationContainer))

OnTranscodeUpdate shows transcode information when a transcoding stream changes parameters

type PMSDevices

type PMSDevices struct {
	Name                 string       `json:"name" xml:"name,attr"`
	Product              string       `json:"product" xml:"product,attr"`
	ProductVersion       string       `json:"productVersion" xml:"productVersion,attr"`
	Platform             string       `json:"platform" xml:"platform,attr"`
	PlatformVersion      string       `json:"platformVersion" xml:"platformVersion,attr"`
	Device               string       `json:"device" xml:"device,attr"`
	ClientIdentifier     string       `json:"clientIdentifier" xml:"clientIdentifier,attr"`
	CreatedAt            string       `json:"createdAt" xml:"createdAt,attr"`
	LastSeenAt           string       `json:"lastSeenAt" xml:"lastSeenAt,attr"`
	Provides             string       `json:"provides" xml:"provides,attr"`
	Owned                string       `json:"owned" xml:"owned,attr"`
	AccessToken          string       `json:"accessToken" xml:"accessToken,attr"`
	HTTPSRequired        int          `json:"httpsRequired" xml:"httpsRequired,attr"`
	Synced               string       `json:"synced" xml:"synced,attr"`
	Relay                int          `json:"relay" xml:"relay,attr"`
	PublicAddressMatches string       `json:"publicAddressMatches" xml:"publicAddressMatches,attr"`
	PublicAddress        string       `json:"publicAddress" xml:"publicAddress,attr"`
	Presence             string       `json:"presence" xml:"presence,attr"`
	Connection           []Connection `json:"connection" xml:"Connection"`
}

PMSDevices is the result of the https://plex.tv/pms/resources endpoint

type Part

type Part struct {
	AudioProfile          string   `json:"audioProfile"`
	Container             string   `json:"container"`
	Decision              string   `json:"decision"`
	Duration              int64    `json:"duration"`
	File                  string   `json:"file"`
	Has64bitOffsets       bool     `json:"has64bitOffsets"`
	HasThumbnail          string   `json:"hasThumbnail"`
	ID                    int      `json:"id"`
	Key                   string   `json:"key"`
	OptimizedForStreaming bool     `json:"optimizedForStreaming"`
	Selected              bool     `json:"selected"`
	Size                  int      `json:"size"`
	Stream                []Stream `json:"Stream"`
	VideoProfile          string   `json:"videoProfile"`
}

Part ...

type PartV1

type PartV1 struct {
	Part
	Duration              int64      `json:"duration"`
	Has64bitOffsets       bool       `json:"has64bitOffsets"`
	ID                    int        `json:"id,string"`
	OptimizedForStreaming bool       `json:"optimizedForStreaming"`
	Size                  int        `json:"size"`
	Stream                []StreamV1 `json:"Stream"`
}

PartV1 part version 1

type PinResponse

type PinResponse struct {
	ID               int             `json:"id"`
	Code             string          `json:"code"`
	ClientIdentifier string          `json:"clientIdentifier"`
	CreatedAt        string          `json:"createdAt"`
	ExpiresAt        string          `json:"expiresAt"`
	ExpiresIn        json.Number     `json:"expiresIn"`
	AuthToken        string          `json:"authToken"`
	Errors           []ErrorResponse `json:"errors"`
	Trusted          bool            `json:"trusted"`
	Location         struct {
		Code         string `json:"code"`
		Country      string `json:"country"`
		City         string `json:"city"`
		Subdivisions string `json:"subdivisions"`
		Coordinates  string `json:"coordinates"`
	}
}

PinResponse holds information to successfully check a pin when linking an account

func CheckPIN

func CheckPIN(id int, clientIdentifier string) (PinResponse, error)

CheckPIN will return information related to the pin such as the auth token if your code has been approved. will return an error if code expired or still not linked clientIdentifier must be the same when requesting a pin

func RequestPIN

func RequestPIN(requestHeaders headers) (PinResponse, error)

RequestPIN will retrieve a code (valid for 15 minutes) from plex.tv to link an app to your plex account

type PlaySessionStateNotification

type PlaySessionStateNotification struct {
	ClientIdentifier string `json:"clientIdentifier"`
	GUID             string `json:"guid"`
	Key              string `json:"key"`
	PlayQueueItemID  int64  `json:"playQueueItemID"`
	PlayQueueID      int64  `json:"playQueueID"`
	RatingKey        string `json:"ratingKey"`
	SessionKey       string `json:"sessionKey"`
	State            string `json:"state"`
	URL              string `json:"url"`
	ViewOffset       int64  `json:"viewOffset"`
	TranscodeSession string `json:"transcodeSession"`
}

PlaySessionStateNotification ...

type Player

type Player struct {
	Address             string `json:"address"`
	Device              string `json:"device"`
	Local               bool   `json:"local"`
	MachineIdentifier   string `json:"machineIdentifier"`
	Model               string `json:"model"`
	Platform            string `json:"platform"`
	PlatformVersion     string `json:"platformVersion"`
	Product             string `json:"product"`
	Profile             string `json:"profile"`
	RemotePublicAddress string `json:"remotePublicAddress"`
	State               string `json:"state"`
	Title               string `json:"title"`
	UserID              int    `json:"userID"`
	Vendor              string `json:"vendor"`
	Version             string `json:"version"`
}

Player ...

type Plex

type Plex struct {
	URL              string
	Token            string
	ClientIdentifier string
	Headers          headers
	HTTPClient       http.Client
	DownloadClient   http.Client
}

Plex contains fields that are required to make an api call to your plex server

func New

func New(baseURL, token string) (*Plex, error)

New creates a new plex instance that is required to to make requests to your Plex Media Server

func SignIn

func SignIn(username, password string) (*Plex, error)

SignIn creates a plex instance using a user name and password instead of an auth token.

func (*Plex) AddLabelToMedia

func (p *Plex) AddLabelToMedia(mediaType, sectionID, id, label, locked string) (bool, error)

AddLabelToMedia restrict access to certain media. Requires a Plex Pass. mediaType is the media type (1), id is the ratingKey or media id, label is your label, locked is unknown 1. A reference to the plex media types: https://github.com/Arcanemagus/plex-api/wiki/MediaTypes XXX: Currently plex is capitalizing the first letter

func (Plex) AddWebhook

func (p Plex) AddWebhook(webhook string) error

AddWebhook creates a new webhook for your plex server to send metadata - requires plex pass

func (*Plex) CheckUsernameOrEmail

func (p *Plex) CheckUsernameOrEmail(usernameOrEmail string) (bool, error)

CheckUsernameOrEmail will check if the username is a Plex user or will verify an email is valid

func (*Plex) CreateLibrary

func (p *Plex) CreateLibrary(params CreateLibraryParams) error

CreateLibrary will create a new library on your Plex server

func (*Plex) DeleteLibrary

func (p *Plex) DeleteLibrary(key string) error

DeleteLibrary removes the library from your Plex server via library key (or id)

func (*Plex) DeletePlexToken

func (p *Plex) DeletePlexToken(token string) (bool, error)

DeletePlexToken is currently not tested

func (*Plex) Download added in v1.0.3

func (p *Plex) Download(meta Metadata, path string, createFolders bool, skipIfExists bool) error

Download media associated with metadata

func (*Plex) ExtractKeyAndThumbFromURL

func (p *Plex) ExtractKeyAndThumbFromURL(_url string) (string, string)

ExtractKeyAndThumbFromURL extracts the rating key and thumbnail id from the url

func (*Plex) ExtractKeyFromRatingKey

func (*Plex) ExtractKeyFromRatingKey(key string) string

ExtractKeyFromRatingKey extracts the key from the rating key url

func (*Plex) ExtractKeyFromRatingKeyRegex

func (p *Plex) ExtractKeyFromRatingKeyRegex(key string) string

ExtractKeyFromRatingKeyRegex extracts the key from a rating key url via regex

func (*Plex) GetDevices

func (p *Plex) GetDevices() ([]PMSDevices, error)

GetServerDevices returns a list of your Plex devices (servers, players, controllers, etc)

func (*Plex) GetEpisode

func (p *Plex) GetEpisode(key string) (SearchResultsEpisode, error)

GetEpisode returns a single episode of a show.

func (*Plex) GetEpisodes

func (p *Plex) GetEpisodes(key string) (SearchResultsEpisode, error)

GetEpisodes returns episodes of a season of a show

func (*Plex) GetFriends

func (p *Plex) GetFriends() ([]Friends, error)

GetFriends returns all of your plex friends

func (*Plex) GetLibraries

func (p *Plex) GetLibraries() (LibrarySections, error)

GetLibraries of your Plex server. My ideal use-case would be to get library count to determine label index

func (*Plex) GetLibraryContent

func (p *Plex) GetLibraryContent(sectionKey string, filter string) (SearchResults, error)

GetLibraryContent retrieve the content inside a library

func (*Plex) GetLibraryLabels

func (p *Plex) GetLibraryLabels(sectionKey, sectionIndex string) (LibraryLabels, error)

GetLibraryLabels of your plex server

func (*Plex) GetMachineID

func (p *Plex) GetMachineID() (string, error)

GetMachineID returns the machine id of the server with the associated access token

func (*Plex) GetMetadata

func (p *Plex) GetMetadata(key string) (MediaMetadata, error)

GetMetadata can get some media info

func (*Plex) GetMetadataChildren

func (p *Plex) GetMetadataChildren(key string) (MetadataChildren, error)

GetMetadataChildren can get a show's season titles. My use-case would be getting the season titles after using Search()

func (*Plex) GetOnDeck

func (p *Plex) GetOnDeck() (SearchResultsEpisode, error)

GetOnDeck gets the on-deck videos.

func (*Plex) GetPlaylist

func (p *Plex) GetPlaylist(key int) (SearchResultsEpisode, error)

GetPlaylist gets all videos in a playlist.

func (*Plex) GetPlexTokens

func (p *Plex) GetPlexTokens(token string) (DevicesResponse, error)

GetPlexTokens not sure if it works

func (*Plex) GetSections

func (p *Plex) GetSections(machineID string) ([]ServerSections, error)

GetSections of your plex server. This is useful when inviting a user as you can restrict the invited user to a library (i.e. Movie's, TV Shows)

func (*Plex) GetServerDevices added in v1.1.5

func (p *Plex) GetServerDevices() ([]PMSDevices, error)

GetServerDevices returns a list of Plex servers with some added info, notably connection data

func (*Plex) GetServers

func (p *Plex) GetServers() ([]PMSDevices, error)

GetServers returns a list of your Plex servers

func (*Plex) GetServersInfo

func (p *Plex) GetServersInfo() (ServerInfo, error)

GetServersInfo returns info about all of your Plex servers

func (*Plex) GetSessions

func (p *Plex) GetSessions() (CurrentSessions, error)

GetSessions of devices currently consuming media

func (*Plex) GetThumbnail

func (p *Plex) GetThumbnail(key, thumbnailID string) (*http.Response, error)

GetThumbnail returns the response of a request to pms thumbnail My ideal use case would be to proxy a request to pms without exposing the plex token

func (*Plex) GetTranscodeSessions

func (p *Plex) GetTranscodeSessions() (TranscodeSessionsResponse, error)

GetTranscodeSessions retrieves a list of all active transcode sessions

func (Plex) GetWebhooks

func (p Plex) GetWebhooks() ([]string, error)

GetWebhooks fetches all webhooks - requires plex pass

func (*Plex) InviteFriend

func (p *Plex) InviteFriend(params InviteFriendParams) error

InviteFriend to access your Plex server. Add restrictions to media or give them full access.

func (*Plex) KillTranscodeSession

func (p *Plex) KillTranscodeSession(sessionKey string) (bool, error)

KillTranscodeSession stops a transcode session

func (Plex) LinkAccount

func (p Plex) LinkAccount(code string) error

LinkAccount allows you to authorize an app via a 4 character pin. returns nil on success

func (Plex) MyAccount

func (p Plex) MyAccount() (UserPlexTV, error)

MyAccount gets account info (i.e. plex pass, servers, username, etc) from plex tv

func (*Plex) RemoveFriend

func (p *Plex) RemoveFriend(id string) (bool, error)

RemoveFriend from your friend's list which stops access to your Plex server

func (*Plex) RemoveFriendAccessToLibrary

func (p *Plex) RemoveFriendAccessToLibrary(userID, machineID, serverID string) (bool, error)

RemoveFriendAccessToLibrary you can individually revoke access to a library on your server. Such as movies, tv shows, music, etc

func (*Plex) RemoveLabelFromMedia

func (p *Plex) RemoveLabelFromMedia(mediaType, sectionID, id, label, locked string) (bool, error)

RemoveLabelFromMedia to remove a label from a piece of media Requires a Plex Pass.

func (*Plex) ScanLibrary

func (p *Plex) ScanLibrary(key string) error

ScanLibrary scans the library from your Plex server via library key (or id)

func (*Plex) Scrobble

func (p *Plex) Scrobble(key string) error

Scrobble sets watched status of KEY to watched

func (*Plex) Search

func (p *Plex) Search(title string) (SearchResults, error)

Search your Plex Server for media

func (*Plex) SearchPlex

func (p *Plex) SearchPlex(title string) (SearchResults, error)

SearchPlex searches just like Search, but omits the last 4 results which are not relevant

func (Plex) SetWebhooks

func (p Plex) SetWebhooks(webhooks []string) error

SetWebhooks will set your webhooks to whatever you pass as an argument webhooks with a length of 0 will remove all webhooks

func (*Plex) StopPlayback

func (p *Plex) StopPlayback(machineID string) error

StopPlayback acts as a remote controller and sends the 'stop' command

func (*Plex) SubscribeToNotifications

func (p *Plex) SubscribeToNotifications(events *NotificationEvents, interrupt <-chan interface{}, errCb func(error), doneCb func())

SubscribeToNotifications connects to your server via websockets listening for events

func (*Plex) TerminateSession

func (p *Plex) TerminateSession(sessionID string, reason string) error

TerminateSession will end a streaming session - plex pass feature

func (*Plex) Test

func (p *Plex) Test() (bool, error)

Test your connection to your Plex Media Server

func (*Plex) Unscrobble

func (p *Plex) Unscrobble(key string) error

Unscrobble sets watched status of KEY to unwatched

func (*Plex) UpdateFriendAccess

func (p *Plex) UpdateFriendAccess(userID string, params UpdateFriendParams) (bool, error)

UpdateFriendAccess limit your friends access to your plex server

type Provider

type Provider struct {
	Key   string `json:"key"`
	Title string `json:"title"`
	Type  string `json:"type"`
}

Provider ...

type Rating added in v1.1.2

type Rating struct {
	Count int         `json:"count,string"`
	Image string      `json:"image"`
	Type  string      `json:"type"`
	Value FixedRating `json:"value"`
}

Rating ...

type ReachabilityNotification

type ReachabilityNotification struct {
	Reachability bool `json:"reachability"`
}

ReachabilityNotification ...

type Role

type Role struct {
	TaggedData
	Role  string `json:"role"`
	Thumb string `json:"thumb"`
}

Role ...

type SearchMediaContainer

type SearchMediaContainer struct {
	MediaContainer
	Provider []Provider
}

SearchMediaContainer ...

type SearchResults

type SearchResults struct {
	MediaContainer SearchMediaContainer `json:"MediaContainer"`
}

SearchResults ...

type SearchResultsEpisode

type SearchResultsEpisode struct {
	MediaContainer MediaContainer `json:"MediaContainer"`
}

SearchResultsEpisode contains metadata about an episode

type SectionIDResponse

type SectionIDResponse struct {
	XMLName           xml.Name `xml:"MediaContainer"`
	FriendlyName      string   `xml:"friendlyName,attr"`
	Identifier        string   `xml:"identifier,attr"`
	MachineIdentifier string   `xml:"machineIdentifier,attr"`
	Size              int      `xml:"size,attr"`
	Server            []struct {
		Name              string           `xml:"name,attr"`
		Address           string           `xml:"address,attr"`
		Port              string           `xml:"port,attr"`
		Version           string           `xml:"version,attr"`
		Scheme            string           `xml:"scheme,attr"`
		Host              string           `xml:"host,attr"`
		LocalAddresses    string           `xml:"localAddresses,attr"`
		MachineIdentifier string           `xml:"machineIdentifier,attr"`
		CreatedAt         int              `xml:"createdAt,attr"`
		UpdatedAt         int              `xml:"updatedAt,attr"`
		Owned             int              `xml:"owned,attr"`
		Synced            string           `xml:"synced,attr"`
		Section           []ServerSections `xml:"Section"`
	} `xml:"Server"`
}

SectionIDResponse the section id (or library id) of your server useful when inviting a user to the server

type ServerInfo

type ServerInfo struct {
	XMLName           xml.Name `xml:"MediaContainer"`
	FriendlyName      string   `xml:"friendlyName,attr"`
	Identifier        string   `xml:"identifier,attr"`
	MachineIdentifier string   `xml:"machineIdentifier,attr"`
	Size              int      `xml:"size,attr"`
	Server            []struct {
		AccessToken       string `xml:"accessToken,attr"`
		Name              string `xml:"name,attr"`
		Address           string `xml:"address,attr"`
		Port              string `xml:"port,attr"`
		Version           string `xml:"version,attr"`
		Scheme            string `xml:"scheme,attr"`
		Host              string `xml:"host,attr"`
		LocalAddresses    string `xml:"localAddresses,attr"`
		MachineIdentifier string `xml:"machineIdentifier,attr"`
		CreatedAt         string `xml:"createdAt,attr"`
		UpdatedAt         string `xml:"updatedAt,attr"`
		Owned             string `xml:"owned,attr"`
		Synced            string `xml:"synced,attr"`
	} `xml:"Server"`
}

ServerInfo is the result of the https://plex.tv/api/servers endpoint

type ServerSections

type ServerSections struct {
	ID    int    `xml:"id,attr"`
	Key   string `xml:"key,attr"`
	Type  string `xml:"type,attr"`
	Title string `xml:"title,attr"`
}

ServerSections contains information of your library sections

type Session

type Session struct {
	Bandwidth int    `json:"bandwidth"`
	ID        string `json:"id"`
	Location  string `json:"location"`
}

Session ...

type Setting

type Setting struct {
	Advanced bool   `json:"advanced"`
	Default  bool   `json:"default"`
	Group    string `json:"group"`
	Hidden   bool   `json:"hidden"`
	ID       string `json:"id"`
	Label    string `json:"label"`
	Summary  string `json:"summary"`
	Type     string `json:"type"`
	Value    string `json:"value"`
}

Setting ...

type SignInResponse

type SignInResponse UserPlexTV

SignInResponse response from plex.tv sign in

type StatusNotification

type StatusNotification struct {
	Description      string `json:"description"`
	NotificationName string `json:"notificationName"`
	Title            string `json:"title"`
}

StatusNotification ...

type Stream

type Stream struct {
	AlbumGain          string  `json:"albumGain"`
	AlbumPeak          string  `json:"albumPeak"`
	AlbumRange         string  `json:"albumRange"`
	Anamorphic         bool    `json:"anamorphic"`
	AudioChannelLayout string  `json:"audioChannelLayout"`
	BitDepth           int     `json:"bitDepth"`
	Bitrate            int     `json:"bitrate"`
	BitrateMode        string  `json:"bitrateMode"`
	Cabac              string  `json:"cabac"`
	Channels           int     `json:"channels"`
	ChromaLocation     string  `json:"chromaLocation"`
	ChromaSubsampling  string  `json:"chromaSubsampling"`
	Codec              string  `json:"codec"`
	CodecID            string  `json:"codecID"`
	ColorRange         string  `json:"colorRange"`
	ColorSpace         string  `json:"colorSpace"`
	Default            bool    `json:"default"`
	DisplayTitle       string  `json:"displayTitle"`
	Duration           float64 `json:"duration"`
	FrameRate          float64 `json:"frameRate"`
	FrameRateMode      string  `json:"frameRateMode"`
	Gain               string  `json:"gain"`
	HasScalingMatrix   bool    `json:"hasScalingMatrix"`
	Height             int     `json:"height"`
	ID                 int     `json:"id"`
	Index              int     `json:"index"`
	Language           string  `json:"language"`
	LanguageCode       string  `json:"languageCode"`
	Level              int     `json:"level"`
	Location           string  `json:"location"`
	Loudness           string  `json:"loudness"`
	Lra                string  `json:"lra"`
	Peak               string  `json:"peak"`
	PixelAspectRatio   string  `json:"pixelAspectRatio"`
	PixelFormat        string  `json:"pixelFormat"`
	Profile            string  `json:"profile"`
	RefFrames          int     `json:"refFrames"`
	SamplingRate       int     `json:"samplingRate"`
	ScanType           string  `json:"scanType"`
	Selected           bool    `json:"selected"`
	StreamIdentifier   string  `json:"streamIdentifier"`
	StreamType         int     `json:"streamType"`
	Width              int     `json:"width"`
}

Stream ...

type StreamV1

type StreamV1 struct {
	Stream
	BitDepth         int     `json:"bitDepth"`
	Default          bool    `json:"default"`
	Bitrate          int     `json:"bitrate"`
	FrameRate        float64 `json:"frameRate"`
	HasScalingMatrix bool    `json:"hasScalingMatrix"`
	Height           int     `json:"height"`
	Width            int     `json:"width"`
	ID               int     `json:"id,string"`
	Index            int     `json:"index"`
	Level            int     `json:"level"`
	RefFrames        int     `json:"refFrames"`
	StreamType       int     `json:"streamType"`
	Channels         int     `json:"channels"`
	SamplingRate     int     `json:"samplingRate"`
	Selected         bool    `json:"selected"`
}

StreamV1 stream info version 1

type TaggedData

type TaggedData struct {
	Tag    string      `json:"tag"`
	Filter string      `json:"filter"`
	ID     json.Number `json:"id"`
}

TaggedData ...

type TimelineEntry

type TimelineEntry struct {
	Identifier    string `json:"identifier"`
	ItemID        int64  `json:"itemID,string"`
	MetadataState string `json:"metadataState"`
	SectionID     int64  `json:"sectionID,string"`
	State         int64  `json:"state"`
	Title         string `json:"title"`
	Type          int64  `json:"type"`
	UpdatedAt     int64  `json:"updatedAt"`
}

TimelineEntry ...

type Timestamp added in v1.1.0

type Timestamp time.Time

Timestamp defines a timestamp encoded as epoch seconds in JSON

func (Timestamp) MarshalJSON added in v1.1.0

func (t Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON is used to convert the timestamp to JSON

func (Timestamp) String added in v1.1.0

func (t Timestamp) String() string

String returns t as a formatted string

func (Timestamp) Time added in v1.1.0

func (t Timestamp) Time() time.Time

Time returns the JSON time as a time.Time instance in UTC

func (Timestamp) Unix added in v1.1.0

func (t Timestamp) Unix() int64

Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC. The result does not depend on the location associated with t.

func (*Timestamp) UnmarshalJSON added in v1.1.0

func (t *Timestamp) UnmarshalJSON(s []byte) (err error)

UnmarshalJSON is used to convert the timestamp from JSON

type TranscodeSession

type TranscodeSession struct {
	AudioChannels        int64   `json:"audioChannels"`
	AudioCodec           string  `json:"audioCodec"`
	AudioDecision        string  `json:"audioDecision"`
	Complete             bool    `json:"complete"`
	Container            string  `json:"container"`
	Context              string  `json:"context"`
	Duration             int64   `json:"duration"`
	Key                  string  `json:"key"`
	Progress             float64 `json:"progress"`
	Protocol             string  `json:"protocol"`
	Remaining            int64   `json:"remaining"`
	SourceAudioCodec     string  `json:"sourceAudioCodec"`
	SourceVideoCodec     string  `json:"sourceVideoCodec"`
	Speed                float64 `json:"speed"`
	Throttled            bool    `json:"throttled"`
	TranscodeHwRequested bool    `json:"transcodeHwRequested"`
	VideoCodec           string  `json:"videoCodec"`
	VideoDecision        string  `json:"videoDecision"`
}

TranscodeSession ...

type TranscodeSessionsResponse

type TranscodeSessionsResponse struct {
	Children []struct {
		ElementType   string  `json:"_elementType"`
		AudioChannels int     `json:"audioChannels"`
		AudioCodec    string  `json:"audioCodec"`
		AudioDecision string  `json:"audioDecision"`
		Container     string  `json:"container"`
		Context       string  `json:"context"`
		Duration      int     `json:"duration"`
		Height        int     `json:"height"`
		Key           string  `json:"key"`
		Progress      float64 `json:"progress"`
		Protocol      string  `json:"protocol"`
		Remaining     int     `json:"remaining"`
		Speed         float64 `json:"speed"`
		Throttled     bool    `json:"throttled"`
		VideoCodec    string  `json:"videoCodec"`
		VideoDecision string  `json:"videoDecision"`
		Width         int     `json:"width"`
	} `json:"_children"`
	ElementType string `json:"_elementType"`
}

TranscodeSessionsResponse is the result for transcode session endpoint /transcode/sessions

type UpdateFriendParams

type UpdateFriendParams struct {
	AllowSync         string
	AllowCameraUpload string
	AllowChannels     string
	FilterMovies      string
	FilterTelevision  string
	FilterMusic       string
	FilterPhotos      string
}

UpdateFriendParams optional parameters to update your friends access to your server

type User

type User struct {
	// ID is an int when signing in to Plex.tv but a string when access own server
	ID                  string `json:"id"`
	UUID                string `json:"uuid"`
	Email               string `json:"email"`
	JoinedAt            string `json:"joined_at"`
	Username            string `json:"username"`
	Thumb               string `json:"thumb"`
	HasPassword         bool   `json:"hasPassword"`
	AuthToken           string `json:"authToken"`
	AuthenticationToken string `json:"authenticationToken"`
	Subscription        struct {
		Active   bool     `json:"active"`
		Status   string   `json:"Active"`
		Plan     string   `json:"lifetime"`
		Features []string `json:"features"`
	} `json:"subscription"`
	Roles struct {
		Roles []string `json:"roles"`
	} `json:"roles"`
	Entitlements []string `json:"entitlements"`
	ConfirmedAt  string   `json:"confirmedAt"`
	ForumID      string   `json:"forumId"`
	RememberMe   bool     `json:"rememberMe"`
	Title        string   `json:"title"`
}

User plex server user. only difference is id is a string

type UserPlexTV

type UserPlexTV struct {
	XMLName xml.Name `xml:"user"`
	// ID is an int when signing in to Plex.tv but a string when access own server
	ID                  int    `json:"id" xml:"id,attr"`
	UUID                string `json:"uuid" xml:"uuid,attr"`
	Email               string `json:"email" xml:"email,attr"`
	JoinedAt            string `json:"joined_at" xml:"joined-at"`
	Username            string `json:"username" xml:"username,attr"`
	Thumb               string `json:"thumb" xml:"thumb,attr"`
	HasPassword         bool   `json:"hasPassword" xml:"hasPassword,attr"`
	AuthToken           string `json:"authToken" xml:"authToken,attr"`
	AuthenticationToken string `json:"authenticationToken" xml:"authentificationToken,attr"`
	Subscription        struct {
		Active  bool   `json:"active" xml:"active,attr"`
		Status  string `json:"Active" xml:"status,attr"`
		Plan    string `json:"lifetime" xml:"plan,attr"`
		Feature []struct {
			ID string `json:"id" xml:"id,attr"`
		} `json:"feature" xml:"feature"`
	} `json:"subscription" xml:"subscription"`
	Roles struct {
		Role []struct {
			ID string `json:"id" xml:"id,attr"`
		} `json:"roles" xml:"role"`
	} `json:"roles" xml:"roles"`
	Entitlements []struct {
		Entitlement []struct {
			ID string `json:"id" xml:"id,attr"`
		} `json:"entitlement" xml:"entitlement"`
	} `json:"entitlements" xml:"entitlements"`
	ConfirmedAt string      `json:"confirmedAt"`
	ForumID     json.Number `json:"forumId"`
	RememberMe  bool        `json:"rememberMe"`
	Title       string      `json:"title" xml:"title,attr"`
}

UserPlexTV plex.tv user. should be used when interacting with plex.tv as the id is an int

type Webhook

type Webhook 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"`
		MediaType            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"`
}

Webhook contains a webhooks information

type WebhookEvents

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

WebhookEvents holds the actions for each webhook events

func NewWebhook

func NewWebhook() *WebhookEvents

NewWebhook inits and returns a webhook event

func (*WebhookEvents) Handler

func (wh *WebhookEvents) Handler(w http.ResponseWriter, r *http.Request)

Handler listens for plex webhooks and executes the corresponding function

func (*WebhookEvents) OnPause

func (wh *WebhookEvents) OnPause(fn func(w Webhook)) error

OnPause executes when the webhook receives a pause event

func (*WebhookEvents) OnPlay

func (wh *WebhookEvents) OnPlay(fn func(w Webhook)) error

OnPlay executes when the webhook receives a play event

func (*WebhookEvents) OnRate

func (wh *WebhookEvents) OnRate(fn func(w Webhook)) error

OnRate executes when the webhook receives a rate event

func (*WebhookEvents) OnResume

func (wh *WebhookEvents) OnResume(fn func(w Webhook)) error

OnResume executes when the webhook receives a resume event

func (*WebhookEvents) OnScrobble

func (wh *WebhookEvents) OnScrobble(fn func(w Webhook)) error

OnScrobble executes when the webhook receives a scrobble event

func (*WebhookEvents) OnStop

func (wh *WebhookEvents) OnStop(fn func(w Webhook)) error

OnStop executes when the webhook receives a stop event

type WebsocketNotification

type WebsocketNotification struct {
	NotificationContainer `json:"NotificationContainer"`
}

WebsocketNotification websocket payload of notifications from a plex media server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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