Documentation ¶
Index ¶
- Constants
- func GetMediaType(info MediaMetadata) string
- func GetMediaTypeID(mediaType string) string
- type ActivityNotification
- type AltGUID
- type BackgroundProcessingQueueEventNotification
- type BaseAPIResponse
- type Connection
- type CreateLibraryParams
- type CurrentSessions
- type DevicesResponse
- type Directory
- type ErrorResponse
- type Friends
- type InviteFriendParams
- type InvitedFriend
- type LibraryLabels
- type LibrarySections
- type Location
- type Media
- type MediaContainer
- type MediaMetadata
- type Metadata
- type MetadataChildren
- type NotificationContainer
- type NotificationEvents
- type PMSDevices
- type Part
- type PinResponse
- type PlaySessionStateNotification
- type Player
- type Plex
- func (p *Plex) AddLabelToMedia(mediaType, sectionID, id, label, locked string) (bool, error)
- func (p Plex) AddWebhook(webhook string) error
- func (p *Plex) CheckUsernameOrEmail(usernameOrEmail string) (bool, error)
- func (p *Plex) CreateLibrary(params CreateLibraryParams) error
- func (p *Plex) DeleteLibrary(key string) error
- func (p *Plex) DeleteMediaByID(id string) error
- func (p *Plex) DeletePlexToken(token string) (bool, error)
- func (p *Plex) Download(meta Metadata, path string, createFolders bool, skipIfExists bool) error
- func (p *Plex) ExtractKeyAndThumbFromURL(_url string) (string, string)
- func (*Plex) ExtractKeyFromRatingKey(key string) string
- func (p *Plex) ExtractKeyFromRatingKeyRegex(key string) string
- func (p *Plex) GetDevices() ([]PMSDevices, error)
- func (p *Plex) GetEpisode(key string) (SearchResultsEpisode, error)
- func (p *Plex) GetEpisodes(key string) (SearchResultsEpisode, error)
- func (p *Plex) GetFriends() ([]Friends, error)
- func (p *Plex) GetInvitedFriends() ([]InvitedFriend, error)
- func (p *Plex) GetLibraries() (LibrarySections, error)
- func (p *Plex) GetLibraryContent(sectionKey string, filter string) (SearchResults, error)
- func (p *Plex) GetLibraryLabels(sectionKey, sectionIndex string) (LibraryLabels, error)
- func (p *Plex) GetMachineID() (string, error)
- func (p *Plex) GetMetadata(key string) (MediaMetadata, error)
- func (p *Plex) GetMetadataChildren(key string) (MetadataChildren, error)
- func (p *Plex) GetOnDeck() (SearchResultsEpisode, error)
- func (p *Plex) GetPlaylist(key int) (SearchResultsEpisode, error)
- func (p *Plex) GetPlexTokens(token string) (DevicesResponse, error)
- func (p *Plex) GetSections(machineID string) ([]ServerSections, error)
- func (p *Plex) GetServers() ([]PMSDevices, error)
- func (p *Plex) GetServersInfo() (ServerInfo, error)
- func (p *Plex) GetSessions() (CurrentSessions, error)
- func (p *Plex) GetThumbnail(key, thumbnailID string) (*http.Response, error)
- func (p *Plex) GetTranscodeSessions() (TranscodeSessionsResponse, error)
- func (p Plex) GetWebhooks() ([]string, error)
- func (p *Plex) InviteFriend(params InviteFriendParams) error
- func (p *Plex) KillTranscodeSession(sessionKey string) (bool, error)
- func (p Plex) LinkAccount(code string) error
- func (p Plex) MyAccount() (UserPlexTV, error)
- func (p *Plex) RemoveFriend(id string) (bool, error)
- func (p *Plex) RemoveFriendAccessToLibrary(userID, machineID, serverID string) (bool, error)
- func (p *Plex) RemoveInvitedFriend(inviteID string, isFriend, isServer, isHome bool) (bool, error)
- func (p *Plex) RemoveLabelFromMedia(mediaType, sectionID, id, label, locked string) (bool, error)
- func (p *Plex) Search(title string) (SearchResults, error)
- func (p *Plex) SearchPlex(title string) (SearchResults, error)
- func (p Plex) SetWebhooks(webhooks []string) error
- func (p *Plex) StopPlayback(machineID string) error
- func (p *Plex) SubscribeToNotifications(events *NotificationEvents, interrupt <-chan os.Signal, fn func(error))
- func (p *Plex) TerminateSession(sessionID string, reason string) error
- func (p *Plex) Test() (bool, error)
- func (p *Plex) UpdateFriendAccess(userID string, params UpdateFriendParams) (bool, error)
- type Provider
- type Rating
- type ReachabilityNotification
- type Role
- type SearchMediaContainer
- type SearchResults
- type SearchResultsEpisode
- type SectionIDResponse
- type ServerInfo
- type ServerSections
- type Services
- type Session
- type Setting
- type SignInResponse
- type StatusNotification
- type Stream
- type TaggedData
- type TimelineEntry
- type TranscodeSession
- type TranscodeSessionsResponse
- type UpdateFriendParams
- type User
- type UserPlexTV
- type Webhook
- type WebhookEvents
- func (wh *WebhookEvents) Handler(w http.ResponseWriter, r *http.Request)
- func (wh *WebhookEvents) OnPause(fn func(w Webhook)) error
- func (wh *WebhookEvents) OnPlay(fn func(w Webhook)) error
- func (wh *WebhookEvents) OnRate(fn func(w Webhook)) error
- func (wh *WebhookEvents) OnResume(fn func(w Webhook)) error
- func (wh *WebhookEvents) OnScrobble(fn func(w Webhook)) error
- func (wh *WebhookEvents) OnStop(fn func(w Webhook)) error
- type WebsocketNotification
Constants ¶
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" ErrorWebhook = "webhook error: %s" )
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 ¶
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 ¶
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"` }
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 []Metadata `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 ¶
ErrorResponse contains a code and an error message
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 InvitedFriend ¶
type InvitedFriend struct { ID string `xml:"id,attr"` CreatedAt string `xml:"createdAt,attr"` IsFriend bool `xml:"friend,attr"` IsHome bool `xml:"home,attr"` IsServer bool `xml:"server,attr"` Username string `xml:"username,attr"` Email string `xml:"email,attr"` Thumb string `xml:"thumb,attr"` FriendlyName string `xml:"friendlyName,attr"` Server struct { Name string `xml:"name,attr"` NumLibraries string `xml:"numLibraries,attr"` } `xml:"Server"` }
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 Media ¶
type Media struct { AspectRatio json.Number `json:"aspectRatio"` AudioChannels int `json:"audioChannels"` AudioCodec string `json:"audioCodec"` AudioProfile string `json:"audioProfile"` Bitrate int `json:"bitrate"` Container string `json:"container"` Duration int `json:"duration"` Has64bitOffsets bool `json:"has64bitOffsets"` Height int `json:"height"` ID json.Number `json:"id"` OptimizedForStreaming boolOrInt `json:"optimizedForStreaming"` // plex can return int (GetMetadata(), GetPlaylist()) or boolean (GetSessions()): 0 or 1; true or false 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 Metadata ¶
type Metadata struct { Player Player `json:"Player"` Session Session `json:"Session"` User User `json:"User"` AddedAt int `json:"addedAt"` Art string `json:"art"` ContentRating string `json:"contentRating"` Duration int `json:"duration"` GrandparentArt string `json:"grandparentArt"` 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 json.Number `json:"librarySectionID"` LibrarySectionKey string `json:"librarySectionKey"` LibrarySectionTitle string `json:"librarySectionTitle"` OriginallyAvailableAt string `json:"originallyAvailableAt"` ParentIndex int64 `json:"parentIndex"` ParentKey string `json:"parentKey"` ParentRatingKey string `json:"parentRatingKey"` ParentThumb string `json:"parentThumb"` ParentTitle string `json:"parentTitle"` RatingCount int `json:"ratingCount"` 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"` 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 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 int `json:"duration"` File string `json:"file"` Has64bitOffsets bool `json:"has64bitOffsets"` HasThumbnail string `json:"hasThumbnail"` ID json.Number `json:"id"` Key string `json:"key"` OptimizedForStreaming boolOrInt `json:"optimizedForStreaming"` Selected bool `json:"selected"` Size int `json:"size"` Stream []Stream `json:"Stream"` VideoProfile string `json:"videoProfile"` }
Part ...
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 { GUID string `json:"guid"` Key string `json:"key"` PlayQueueItemID int64 `json:"playQueueItemID"` 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 ¶
New creates a new plex instance that is required to to make requests to your Plex Media Server
func SignIn ¶
SignIn creates a plex instance using a user name and password instead of an auth token.
func (*Plex) AddLabelToMedia ¶
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 ¶
AddWebhook creates a new webhook for your plex server to send metadata - requires plex pass
func (*Plex) CheckUsernameOrEmail ¶
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 ¶
DeleteLibrary removes the library from your Plex server via library key (or id)
func (*Plex) DeleteMediaByID ¶
DeleteMediaByID removes the media from your Plex server via media key (or id)
func (*Plex) DeletePlexToken ¶
DeletePlexToken is currently not tested
func (*Plex) ExtractKeyAndThumbFromURL ¶
ExtractKeyAndThumbFromURL extracts the rating key and thumbnail id from the url
func (*Plex) ExtractKeyFromRatingKey ¶
ExtractKeyFromRatingKey extracts the key from the rating key url
func (*Plex) ExtractKeyFromRatingKeyRegex ¶
ExtractKeyFromRatingKeyRegex extracts the key from a rating key url via regex
func (*Plex) GetDevices ¶
func (p *Plex) GetDevices() ([]PMSDevices, error)
GetDevices 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 ¶
GetFriends returns all of your plex friends
func (*Plex) GetInvitedFriends ¶
func (p *Plex) GetInvitedFriends() ([]InvitedFriend, error)
GetInvitedFriends get all invited friends with request still pending
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 ¶
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) 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 ¶
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 ¶
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 ¶
KillTranscodeSession stops a transcode session
func (Plex) LinkAccount ¶
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 ¶
RemoveFriend from your friend's list which stops access to your Plex server
func (*Plex) RemoveFriendAccessToLibrary ¶
RemoveFriendAccessToLibrary you can individually revoke access to a library on your server. Such as movies, tv shows, music, etc
func (*Plex) RemoveInvitedFriend ¶
RemoveInvitedFriend cancel pending friend invite
func (*Plex) RemoveLabelFromMedia ¶
RemoveLabelFromMedia to remove a label from a piece of media Requires a Plex Pass.
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 ¶
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 ¶
StopPlayback acts as a remote controller and sends the 'stop' command
func (*Plex) SubscribeToNotifications ¶
func (p *Plex) SubscribeToNotifications(events *NotificationEvents, interrupt <-chan os.Signal, fn func(error))
SubscribeToNotifications connects to your server via websockets listening for events
func (*Plex) TerminateSession ¶
TerminateSession will end a streaming session - plex pass feature
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 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 string `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 int64 `json:"value"` }
Setting ...
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 string `json:"duration"` FrameRate float64 `json:"frameRate"` FrameRateMode string `json:"frameRateMode"` Gain string `json:"gain"` HasScalingMatrix bool `json:"hasScalingMatrix"` Height int `json:"height"` ID json.Number `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 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"` MetadataState string `json:"metadataState"` SectionID int64 `json:"sectionID"` State int64 `json:"state"` Title string `json:"title"` Type int64 `json:"type"` UpdatedAt int64 `json:"updatedAt"` }
TimelineEntry ...
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 { ID int `json:"id"` UUID string `json:"uuid"` Username string `json:"username"` Title string `json:"title"` Email string `json:"email"` FriendlyName string `json:"friendlyName"` Locale interface{} `json:"locale"` Confirmed bool `json:"confirmed"` JoinedAt int `json:"joinedAt"` EmailOnlyAuth bool `json:"emailOnlyAuth"` HasPassword bool `json:"hasPassword"` Protected bool `json:"protected"` Thumb string `json:"thumb"` AuthToken string `json:"authToken"` MailingListStatus string `json:"mailingListStatus"` MailingListActive bool `json:"mailingListActive"` ScrobbleTypes string `json:"scrobbleTypes"` Country string `json:"country"` Pin string `json:"pin"` Subscription struct { Active bool `json:"active"` SubscribedAt time.Time `json:"subscribedAt"` Status string `json:"status"` PaymentService string `json:"paymentService"` Plan string `json:"plan"` Features []string `json:"features"` } `json:"subscription"` SubscriptionDescription string `json:"subscriptionDescription"` Restricted bool `json:"restricted"` Anonymous interface{} `json:"anonymous"` Home bool `json:"home"` Guest bool `json:"guest"` HomeSize int `json:"homeSize"` HomeAdmin bool `json:"homeAdmin"` MaxHomeSize int `json:"maxHomeSize"` RememberExpiresAt int `json:"rememberExpiresAt"` Profile struct { AutoSelectAudio bool `json:"autoSelectAudio"` DefaultAudioLanguage string `json:"defaultAudioLanguage"` DefaultSubtitleLanguage string `json:"defaultSubtitleLanguage"` AutoSelectSubtitle int `json:"autoSelectSubtitle"` DefaultSubtitleAccessibility int `json:"defaultSubtitleAccessibility"` DefaultSubtitleForced int `json:"defaultSubtitleForced"` } `json:"profile"` Entitlements []string `json:"entitlements"` Roles []string `json:"roles"` Services []struct { Identifier string `json:"identifier"` Endpoint string `json:"endpoint"` Token string `json:"token"` Secret interface{} `json:"secret"` Status string `json:"status"` } `json:"services"` AdsConsent interface{} `json:"adsConsent"` AdsConsentSetAt interface{} `json:"adsConsentSetAt"` AdsConsentReminderAt interface{} `json:"adsConsentReminderAt"` ExperimentalFeatures bool `json:"experimentalFeatures"` TwoFactorEnabled bool `json:"twoFactorEnabled"` BackupCodesCreated bool `json:"backupCodesCreated"` }
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 (*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