jellyfin

package
v2.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: GPL-3.0 Imports: 28 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jellyfin indexes a Jellyfin server's library and plays its items on a player the server can remote control.

Index

Constants

This section is empty.

Variables

View Source
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 is returned when the server rejects the access token.
	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")
)
View Source
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")
)
View Source
var ErrNoPlayer = errors.New("no matching jellyfin player")

ErrNoPlayer is returned when no controllable Jellyfin player matches the configured client.

Functions

func DeviceID

func DeviceID(cfg *config.Instance) string

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 Launchers

func Launchers() []platforms.Launcher

Launchers returns all six Jellyfin launchers.

func NewJellyfinAlbumLauncher

func NewJellyfinAlbumLauncher() platforms.Launcher

NewJellyfinAlbumLauncher plays every track of an album in order.

func NewJellyfinArtistLauncher

func NewJellyfinArtistLauncher() platforms.Launcher

NewJellyfinArtistLauncher plays every track by an artist, album by album.

func NewJellyfinMovieLauncher

func NewJellyfinMovieLauncher() platforms.Launcher

NewJellyfinMovieLauncher plays a library movie.

func NewJellyfinSongLauncher

func NewJellyfinSongLauncher() platforms.Launcher

NewJellyfinSongLauncher plays a library song.

func NewJellyfinTVEpisodeLauncher

func NewJellyfinTVEpisodeLauncher() platforms.Launcher

NewJellyfinTVEpisodeLauncher plays a library TV episode.

func NewJellyfinTVShowLauncher

func NewJellyfinTVShowLauncher() platforms.Launcher

NewJellyfinTVShowLauncher plays every episode of a TV show in order.

func NormalizeServerURL

func NormalizeServerURL(raw string) (string, error)

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

func (c *HTTPClient) GetItem(ctx context.Context, id string) (*Item, error)

GetItem returns one item, or ErrItemNotFound when the server has none with that ID.

func (*HTTPClient) ListAlbumArtists

func (c *HTTPClient) ListAlbumArtists(ctx context.Context, query url.Values) (*ItemsPage, error)

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) ListItems

func (c *HTTPClient) ListItems(ctx context.Context, query url.Values) (*ItemsPage, error)

ListItems runs an item query as the token's user.

func (*HTTPClient) Play

func (c *HTTPClient) Play(ctx context.Context, sessionID, command string, itemIDs []string) error

Play sends a play command for items to a session.

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

func (c *HTTPClient) ShowEpisodes(ctx context.Context, showID string) ([]Item, error)

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.

Jump to

Keyboard shortcuts

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