Documentation
¶
Overview ¶
Package jellyfin indexes a Jellyfin server's library and plays its items on a player the server can remote control.
Index ¶
- Variables
- func DeviceID(cfg *config.Instance) string
- func Launchers() []platforms.Launcher
- func NewJellyfinAlbumLauncher() platforms.Launcher
- func NewJellyfinArtistLauncher() platforms.Launcher
- func NewJellyfinMovieLauncher() platforms.Launcher
- func NewJellyfinSongLauncher() platforms.Launcher
- func NewJellyfinTVEpisodeLauncher() platforms.Launcher
- func NewJellyfinTVShowLauncher() platforms.Launcher
- func NormalizeServerURL(raw string) (string, error)
- type Client
- type HTTPClient
- func (c *HTTPClient) ControllableSessions(ctx context.Context) ([]Session, error)
- func (c *HTTPClient) CurrentUserID(ctx context.Context) (string, error)
- func (c *HTTPClient) DeviceID() string
- func (c *HTTPClient) GetItem(ctx context.Context, id string) (*Item, error)
- func (c *HTTPClient) ListAlbumArtists(ctx context.Context, query url.Values) (*ItemsPage, error)
- func (c *HTTPClient) ListItems(ctx context.Context, query url.Values) (*ItemsPage, error)
- func (c *HTTPClient) Play(ctx context.Context, sessionID, command string, itemIDs []string) error
- func (c *HTTPClient) PlayerName() string
- func (c *HTTPClient) SendPlaystate(ctx context.Context, sessionID, command string) error
- func (c *HTTPClient) ShowEpisodes(ctx context.Context, showID string) ([]Item, error)
- type Item
- type ItemsPage
- type LinkClient
- func (c *LinkClient) AuthenticateWithQuickConnect(ctx context.Context, secret string) (string, error)
- func (c *LinkClient) BaseURL() string
- func (c *LinkClient) InitiateQuickConnect(ctx context.Context) (*QuickConnect, error)
- func (c *LinkClient) QuickConnectEnabled(ctx context.Context) (bool, error)
- func (c *LinkClient) QuickConnectState(ctx context.Context, secret string) (*QuickConnect, error)
- func (c *LinkClient) VerificationURL() string
- type QuickConnect
- type Session
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotConfigured is returned when no Jellyfin server URL is set. ErrNotConfigured = errors.New("jellyfin server is not configured") // ErrNotLinked is returned when Core holds no access token for the // configured Jellyfin server. ErrNotLinked = errors.New("jellyfin server is not linked") ErrUnauthorized = errors.New("jellyfin rejected the access token, link the server again") // ErrItemNotFound is returned when the server has no item with an ID. ErrItemNotFound = errors.New("jellyfin item not found") )
var ( // ErrQuickConnectDisabled is returned when the server has Quick Connect // turned off. ErrQuickConnectDisabled = errors.New("quick connect is disabled on this jellyfin server") // ErrQuickConnectExpired is returned when the server no longer knows a // Quick Connect request. ErrQuickConnectExpired = errors.New("jellyfin quick connect request expired") )
var ErrNoPlayer = errors.New("no matching jellyfin player")
ErrNoPlayer is returned when no controllable Jellyfin player matches the configured client.
Functions ¶
func DeviceID ¶
DeviceID is the stable device ID Core sends to Jellyfin. Jellyfin ties an access token to it and revokes a device's old token when the same device links again, so the link flow and the client must agree on it.
func NewJellyfinAlbumLauncher ¶
NewJellyfinAlbumLauncher plays every track of an album in order.
func NewJellyfinArtistLauncher ¶
NewJellyfinArtistLauncher plays every track by an artist, album by album.
func NewJellyfinMovieLauncher ¶
NewJellyfinMovieLauncher plays a library movie.
func NewJellyfinSongLauncher ¶
NewJellyfinSongLauncher plays a library song.
func NewJellyfinTVEpisodeLauncher ¶
NewJellyfinTVEpisodeLauncher plays a library TV episode.
func NewJellyfinTVShowLauncher ¶
NewJellyfinTVShowLauncher plays every episode of a TV show in order.
func NormalizeServerURL ¶
NormalizeServerURL turns a user-entered server address into the base URL Core stores: http or https, no credentials, query or fragment, and no trailing slash. An address without a scheme is taken as http.
Types ¶
type Client ¶
type Client interface {
// PlayerName is the configured player, empty when none is configured.
PlayerName() string
// DeviceID is the device ID Core identifies itself with.
DeviceID() string
CurrentUserID(ctx context.Context) (string, error)
ControllableSessions(ctx context.Context) ([]Session, error)
GetItem(ctx context.Context, id string) (*Item, error)
ListItems(ctx context.Context, query url.Values) (*ItemsPage, error)
ListAlbumArtists(ctx context.Context, query url.Values) (*ItemsPage, error)
ShowEpisodes(ctx context.Context, showID string) ([]Item, error)
Play(ctx context.Context, sessionID, command string, itemIDs []string) error
SendPlaystate(ctx context.Context, sessionID, command string) error
}
Client is the Jellyfin API surface the launchers, scanner and controls use.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient talks to a Jellyfin server over its REST API.
func NewClient ¶
func NewClient(serverURL, token, player, deviceID string) (*HTTPClient, error)
NewClient returns a client for serverURL authenticated with token, playing on the named player.
func NewClientWithLauncherID ¶
func NewClientWithLauncherID(cfg *config.Instance, launcherID string, groups []string) (*HTTPClient, error)
NewClientWithLauncherID returns a client for the server and player the launcher's merged configuration names. It fails with ErrNotConfigured when no server URL is set and ErrNotLinked when Core holds no token for it.
func (*HTTPClient) ControllableSessions ¶
func (c *HTTPClient) ControllableSessions(ctx context.Context) ([]Session, error)
ControllableSessions lists the sessions the token's user may remote control.
func (*HTTPClient) CurrentUserID ¶
func (c *HTTPClient) CurrentUserID(ctx context.Context) (string, error)
CurrentUserID returns the ID of the user the token belongs to.
func (*HTTPClient) DeviceID ¶
func (c *HTTPClient) DeviceID() string
DeviceID returns the device ID Core identifies itself with.
func (*HTTPClient) GetItem ¶
GetItem returns one item, or ErrItemNotFound when the server has none with that ID.
func (*HTTPClient) ListAlbumArtists ¶
ListAlbumArtists runs an album artist query as the token's user. Artists are not children of a library folder, so /Items does not list them.
func (*HTTPClient) PlayerName ¶
func (c *HTTPClient) PlayerName() string
PlayerName returns the configured player name.
func (*HTTPClient) SendPlaystate ¶
func (c *HTTPClient) SendPlaystate(ctx context.Context, sessionID, command string) error
SendPlaystate sends a playstate command such as PlayPause to a session.
func (*HTTPClient) ShowEpisodes ¶
ShowEpisodes lists a series' episodes.
type Item ¶
type Item struct {
ProviderIDs map[string]string `json:"ProviderIds"`
ParentIndexNumber *int `json:"ParentIndexNumber"`
IndexNumber *int `json:"IndexNumber"`
ID string `json:"Id"`
Name string `json:"Name"`
Type string `json:"Type"`
SeriesName string `json:"SeriesName"`
Album string `json:"Album"`
AlbumID string `json:"AlbumId"`
AlbumArtist string `json:"AlbumArtist"`
Artists []string `json:"Artists"`
ProductionYear int `json:"ProductionYear"`
}
Item is the part of a Jellyfin BaseItemDto Core uses.
type ItemsPage ¶
type ItemsPage struct {
Items []Item `json:"Items"`
TotalRecordCount int `json:"TotalRecordCount"`
StartIndex int `json:"StartIndex"`
}
ItemsPage is one page of a Jellyfin item query.
type LinkClient ¶
type LinkClient struct {
// contains filtered or unexported fields
}
LinkClient runs Jellyfin's Quick Connect flow, which links Core to a server without Core ever seeing the user's password.
func NewLinkClient ¶
func NewLinkClient(serverURL, deviceID string) (*LinkClient, error)
NewLinkClient returns a Quick Connect client for serverURL.
func (*LinkClient) AuthenticateWithQuickConnect ¶
func (c *LinkClient) AuthenticateWithQuickConnect(ctx context.Context, secret string) (string, error)
AuthenticateWithQuickConnect trades an approved request for an access token.
func (*LinkClient) BaseURL ¶
func (c *LinkClient) BaseURL() string
BaseURL returns the normalized server URL.
func (*LinkClient) InitiateQuickConnect ¶
func (c *LinkClient) InitiateQuickConnect(ctx context.Context) (*QuickConnect, error)
InitiateQuickConnect starts a request and returns its code and secret.
func (*LinkClient) QuickConnectEnabled ¶
func (c *LinkClient) QuickConnectEnabled(ctx context.Context) (bool, error)
QuickConnectEnabled reports whether the server accepts Quick Connect.
func (*LinkClient) QuickConnectState ¶
func (c *LinkClient) QuickConnectState(ctx context.Context, secret string) (*QuickConnect, error)
QuickConnectState reports whether a user has approved the request.
func (*LinkClient) VerificationURL ¶
func (c *LinkClient) VerificationURL() string
VerificationURL is the page of the server's web app where a signed-in user enters a Quick Connect code.
type QuickConnect ¶
type QuickConnect struct {
Secret string `json:"Secret"`
Code string `json:"Code"`
Authenticated bool `json:"Authenticated"`
}
QuickConnect is the state of a Quick Connect request.
type Session ¶
type Session struct {
LastActivityDate time.Time `json:"LastActivityDate"`
NowPlayingItem *Item `json:"NowPlayingItem"`
ID string `json:"Id"`
DeviceName string `json:"DeviceName"`
Client string `json:"Client"`
DeviceID string `json:"DeviceId"`
SupportsRemoteControl bool `json:"SupportsRemoteControl"`
}
Session is the part of a Jellyfin SessionInfo Core uses.