Documentation
¶
Index ¶
- Constants
- type Account
- type ActiveSession
- type Client
- func (c *Client) AddToPlaylist(ctx context.Context, playlistID string, ratingKeys []string) error
- func (c *Client) ApplyMatch(ctx context.Context, ratingKey string, guid string, name string) error
- func (c *Client) CreatePlaylist(ctx context.Context, title string, playlistType string, ratingKeys []string) (*PlaylistInfo, error)
- func (c *Client) CreateSmartPlaylist(ctx context.Context, title string, playlistType string, sectionID string, ...) (*PlaylistInfo, error)
- func (c *Client) DeletePlaylist(ctx context.Context, playlistID string) error
- func (c *Client) FindShow(ctx context.Context, showName string) (string, string, error)
- func (c *Client) GetAccounts(ctx context.Context) ([]Account, error)
- func (c *Client) GetActiveSessions(ctx context.Context) ([]ActiveSession, error)
- func (c *Client) GetAllLibraryItems(ctx context.Context, sectionID string) ([]*components.Metadata, error)
- func (c *Client) GetDirectorID(ctx context.Context, sectionID string, directorName string) (string, error)
- func (c *Client) GetDirectors(ctx context.Context, sectionID string) ([]DirectorInfo, error)
- func (c *Client) GetHistory(ctx context.Context, limit int) ([]HistoryItem, error)
- func (c *Client) GetItemMetadata(ctx context.Context, ratingKey string) (*components.Metadata, error)
- func (c *Client) GetLibraryItemsConcurrent(ctx context.Context, sectionIDs []string, maxConcurrent int) ([]*components.Metadata, error)
- func (c *Client) GetMaxRetries() int
- func (c *Client) GetMoviesByDirector(ctx context.Context, sectionID string, directorName string) ([]MovieInfo, error)
- func (c *Client) GetPlaylistItems(ctx context.Context, playlistID string) ([]SearchResult, error)
- func (c *Client) GetSeasonEpisodes(ctx context.Context, showRatingKey string, seasonNum int) ([]EpisodeInfo, error)
- func (c *Client) GetSections(ctx context.Context) ([]Library, error)
- func (c *Client) GetServerURL() string
- func (c *Client) GetServerUUID(ctx context.Context) (string, error)
- func (c *Client) GetShowEpisodes(ctx context.Context, showRatingKey string) ([]Episode, error)
- func (c *Client) GetStreams(ctx context.Context, ratingKey string) ([]StreamInfo, error)
- func (c *Client) GetTimeout() time.Duration
- func (c *Client) GetWatchHistory(ctx context.Context) ([]HistoryEntry, error)
- func (c *Client) ListPlaylists(ctx context.Context) ([]PlaylistInfo, error)
- func (c *Client) SearchLibrary(ctx context.Context, query string, sectionID *string, limit int) ([]SearchResult, error)
- func (c *Client) SearchMatches(ctx context.Context, ratingKey string, title string, year int) ([]MatchResult, error)
- func (c *Client) SetStreams(ctx context.Context, partID string, audioStreamID, subtitleStreamID int) error
- type ClientOption
- type DirectorInfo
- type Episode
- type EpisodeInfo
- type HistoryEntry
- type HistoryItem
- type Library
- type MatchResult
- type MovieInfo
- type PlaylistInfo
- type PlexError
- type SearchResult
- type StreamInfo
Constants ¶
const ( DefaultTimeout = 120 * time.Second DefaultMaxRetries = 3 DefaultPageSize = 100 DefaultConcurrentWorkers = 4 DefaultHistoryLimit = 50 DefaultSearchLimit = 50 RetryExponent = 2.0 MaxBackoffDuration = 30 * time.Second DefaultClientID = "plexcli" DefaultLibraryPathPrefix = "/library/sections/" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveSession ¶
type ActiveSession struct {
User string `json:"user"`
Title string `json:"title"`
Type string `json:"type"`
Show string `json:"show,omitempty"`
Progress string `json:"progress"`
Device string `json:"device"`
State string `json:"state"`
}
ActiveSession represents a currently playing session
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides access to a Plex server.
func (*Client) AddToPlaylist ¶
AddToPlaylist adds items to an existing playlist
func (*Client) ApplyMatch ¶
ApplyMatch applies a metadata match to an item (like selecting a match in Plex's "Fix Match")
func (*Client) CreatePlaylist ¶
func (c *Client) CreatePlaylist(ctx context.Context, title string, playlistType string, ratingKeys []string) (*PlaylistInfo, error)
CreatePlaylist creates a new playlist with the given name and optional initial items ratingKeys should be a slice of rating keys to add to the playlist
func (*Client) CreateSmartPlaylist ¶
func (c *Client) CreateSmartPlaylist(ctx context.Context, title string, playlistType string, sectionID string, filterType string, filterValue string) (*PlaylistInfo, error)
CreateSmartPlaylist creates a smart playlist based on a filter (e.g., by director) sectionID is the library section, filterType is the filter category (e.g., "director"), filterValue is the filter ID (e.g., director ID from GetDirectors)
func (*Client) DeletePlaylist ¶
DeletePlaylist deletes a playlist by ID
func (*Client) GetAccounts ¶
GetAccounts returns all user accounts on the server
func (*Client) GetActiveSessions ¶
func (c *Client) GetActiveSessions(ctx context.Context) ([]ActiveSession, error)
GetActiveSessions returns currently active playback sessions
func (*Client) GetAllLibraryItems ¶
func (*Client) GetDirectorID ¶
func (c *Client) GetDirectorID(ctx context.Context, sectionID string, directorName string) (string, error)
GetDirectorID looks up a director by name and returns their ID
func (*Client) GetDirectors ¶
GetDirectors returns all directors in a library section
func (*Client) GetHistory ¶
func (*Client) GetItemMetadata ¶
func (c *Client) GetItemMetadata(ctx context.Context, ratingKey string) (*components.Metadata, error)
GetItemMetadata fetches detailed metadata for a single item including streams
func (*Client) GetLibraryItemsConcurrent ¶
func (*Client) GetMaxRetries ¶
func (*Client) GetMoviesByDirector ¶
func (c *Client) GetMoviesByDirector(ctx context.Context, sectionID string, directorName string) ([]MovieInfo, error)
GetMoviesByDirector returns all movies by a given director from a library section The director name matching is case-insensitive and supports partial matches
func (*Client) GetPlaylistItems ¶
GetPlaylistItems returns the items in a playlist
func (*Client) GetSeasonEpisodes ¶
func (c *Client) GetSeasonEpisodes(ctx context.Context, showRatingKey string, seasonNum int) ([]EpisodeInfo, error)
GetSeasonEpisodes returns all episodes for a specific season of a show
func (*Client) GetServerURL ¶
func (*Client) GetServerUUID ¶
GetServerUUID returns the server's machine identifier (UUID)
func (*Client) GetShowEpisodes ¶
GetShowEpisodes returns all episodes for a show given its rating key
func (*Client) GetStreams ¶
GetStreams returns all streams (video, audio, subtitle) for an item
func (*Client) GetTimeout ¶
func (*Client) GetWatchHistory ¶
func (c *Client) GetWatchHistory(ctx context.Context) ([]HistoryEntry, error)
GetWatchHistory returns the watch history
func (*Client) ListPlaylists ¶
func (c *Client) ListPlaylists(ctx context.Context) ([]PlaylistInfo, error)
ListPlaylists returns all playlists
func (*Client) SearchLibrary ¶
func (c *Client) SearchLibrary(ctx context.Context, query string, sectionID *string, limit int) ([]SearchResult, error)
SearchLibrary searches the Plex library for items matching the query
func (*Client) SearchMatches ¶
func (c *Client) SearchMatches(ctx context.Context, ratingKey string, title string, year int) ([]MatchResult, error)
SearchMatches searches for metadata matches for an item (like Plex's "Fix Match" feature)
type ClientOption ¶
type ClientOption func(*Client)
func WithMaxRetries ¶
func WithMaxRetries(maxRetries int) ClientOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
type DirectorInfo ¶
type DirectorInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Count int `json:"count"` // Number of movies by this director
}
DirectorInfo represents a director in the library
type Episode ¶
type Episode struct {
RatingKey string `json:"ratingKey"`
Title string `json:"title"`
ShowTitle string `json:"showTitle"`
SeasonNum int `json:"season"`
EpisodeNum int `json:"episode"`
SeasonTitle string `json:"seasonTitle,omitempty"`
}
Episode represents a TV episode with season/episode info
type EpisodeInfo ¶
EpisodeInfo represents basic episode information
type HistoryEntry ¶
type HistoryEntry struct {
Title string `json:"title"`
Type string `json:"type"`
GrandparentTitle string `json:"grandparent_title,omitempty"`
ParentIndex int `json:"parent_index,omitempty"`
Index int `json:"index,omitempty"`
AccountID int `json:"account_id"`
DeviceID int `json:"device_id"`
ViewedAt time.Time `json:"viewed_at"`
}
HistoryEntry represents a watch history entry
type HistoryItem ¶
type Library ¶
type Library struct {
ID string
Title *string
Type string
Key *string
UUID string
Location []string
}
Library represents a Plex library section.
type MatchResult ¶
type MatchResult struct {
GUID string `json:"guid"`
Name string `json:"name"`
Year int `json:"year,omitempty"`
Summary string `json:"summary,omitempty"`
}
MatchResult represents a potential metadata match for an item
type MovieInfo ¶
type MovieInfo struct {
RatingKey string `json:"ratingKey"`
Title string `json:"title"`
Year int `json:"year"`
Directors []string `json:"directors"`
}
MovieInfo represents a movie with director info
type PlaylistInfo ¶
type PlaylistInfo struct {
RatingKey string `json:"ratingKey"`
Key string `json:"key"`
Title string `json:"title"`
Type string `json:"type"`
PlaylistType string `json:"playlistType"`
LeafCount int `json:"leafCount"`
Smart bool `json:"smart"`
Duration int64 `json:"duration"`
}
PlaylistInfo represents a playlist
type SearchResult ¶
type SearchResult struct {
RatingKey string `json:"ratingKey"`
Key string `json:"key"`
Title string `json:"title"`
Type string `json:"type"`
Year *int `json:"year"`
GrandparentTitle *string `json:"grandparentTitle"`
ParentTitle *string `json:"parentTitle"`
ParentIndex *int `json:"parentIndex"`
Index *int `json:"index"`
Thumb *string `json:"thumb"`
}
SearchResult represents a single search result item
type StreamInfo ¶
type StreamInfo struct {
ID int `json:"id"`
StreamType int `json:"stream_type"`
Language string `json:"language"`
LanguageCode string `json:"language_code"`
Codec string `json:"codec"`
Title string `json:"title,omitempty"`
Channels int `json:"channels,omitempty"`
Selected bool `json:"selected"`
Default bool `json:"default"`
}
StreamInfo represents an audio or subtitle stream