Documentation
¶
Overview ¶
Package plex implements a playlist.Provider for Plex Media Server.
Index ¶
- func IsStreamURL(urlStr string) bool
- type Album
- type Client
- func (c *Client) Albums(sectionKey string) ([]Album, error)
- func (c *Client) MusicSections() ([]Section, error)
- func (c *Client) Ping() error
- func (c *Client) Search(query string) ([]Track, error)
- func (c *Client) StreamURL(partKey string) string
- func (c *Client) Tracks(albumRatingKey string) ([]Track, error)
- type Provider
- func (p *Provider) AlbumTracks(albumID string) ([]playlist.Track, error)
- func (p *Provider) Name() string
- func (p *Provider) Playlists() ([]playlist.PlaylistInfo, error)
- func (p *Provider) Refresh()
- func (p *Provider) SearchTracks(_ context.Context, query string, limit int) ([]playlist.Track, error)
- func (p *Provider) Tracks(albumRatingKey string) ([]playlist.Track, error)
- type Section
- type Track
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsStreamURL ¶
IsStreamURL reports whether the given URL looks like a Plex library part endpoint. Used by the player to route these URLs through the buffered navBuffer + ffmpeg pipeline instead of native HTTP streaming.
Types ¶
type Album ¶
type Album struct {
RatingKey string // unique album ID (Plex ratingKey)
Title string
ArtistName string // parentTitle in the Plex API
Year int
TrackCount int // leafCount
}
Album represents a Plex album with its artist and track count.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client speaks to a Plex Media Server over its HTTP API.
func NewClient ¶
NewClient returns a Client for the given server URL and authentication token. libraries is an optional list of music library names to restrict MusicSections to. When not provided, all music libraries will be loaded
func (*Client) Albums ¶
Albums returns all albums in the given music section (identified by its key). It requests type=9 (album) directly rather than walking artists, and paginates through the full result set using X-Plex-Container-Start / Size.
func (*Client) MusicSections ¶
MusicSections returns library sections of type "artist" (music libraries). When the client was constructed with a library filter, only sections whose title matches one of the allowed names (case-insensitive) are returned.
func (*Client) Ping ¶
Ping checks that the server is reachable and the token is valid. Returns a descriptive error on failure.
func (*Client) Search ¶
Search searches the music library for tracks matching query. Returns nil without making an HTTP call when query is empty.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements playlist.Provider for a Plex Media Server. Playlists() returns all albums across all music library sections. Tracks() returns the tracks for a given album ratingKey.
func NewFromConfig ¶
func NewFromConfig(cfg config.PlexConfig) *Provider
NewFromConfig returns a Provider from a PlexConfig, or nil if URL or Token is missing.
func (*Provider) AlbumTracks ¶
AlbumTracks returns the tracks for the given album (ratingKey). Implements provider.AlbumTrackLoader.
func (*Provider) Playlists ¶
func (p *Provider) Playlists() ([]playlist.PlaylistInfo, error)
Playlists returns all albums across all Plex music library sections. Each album is a PlaylistInfo whose ID is the album's Plex ratingKey. Results are cached after the first successful call.
func (*Provider) Refresh ¶
func (p *Provider) Refresh()
Refresh clears cached playlist and track data so the next call re-fetches from the server. Implements playlist.Refresher.
func (*Provider) SearchTracks ¶
func (p *Provider) SearchTracks(_ context.Context, query string, limit int) ([]playlist.Track, error)
SearchTracks searches the Plex music library for tracks matching query. Implements provider.Searcher.
type Section ¶
type Section struct {
Key string // numeric section ID, e.g. "3"
Title string // display name
Type string // "artist" for music libraries
}
Section represents a Plex library section (e.g. a music library).
type Track ¶
type Track struct {
RatingKey string
Title string
ArtistName string // grandparentTitle
AlbumName string // parentTitle
Year int
TrackNumber int // index field in Plex API
Duration int // milliseconds
PartKey string // relative path, e.g. "/library/parts/67890/1234567890/file.flac"
}
Track represents a Plex track with metadata and its first streamable Part.