embyapi

package
v1.60.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package embyapi implements the shared Emby/Jellyfin HTTP client. The two servers speak nearly the same API; the few differences (auth header scheme, ping endpoint, user-id discovery, error prefix, metadata key) are isolated in a dialect so emby and jellyfin can be thin wrappers over one client.

Index

Constants

View Source
const (
	SortAlbumsByName   = "name"
	SortAlbumsByArtist = "artist"
	SortAlbumsByYear   = "year"
)

Variables

This section is empty.

Functions

func IsStreamURL

func IsStreamURL(path string) bool

IsStreamURL reports whether the given URL looks like an item download endpoint. Used by the player to route these URLs through the buffered ffmpeg pipeline instead of native HTTP streaming.

Types

type Album

type Album struct {
	ID         string
	Name       string
	Artist     string
	ArtistID   string
	Year       int
	TrackCount int
}

Album represents an album entry.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client speaks to an Emby or Jellyfin server over its HTTP API.

func NewEmbyClient

func NewEmbyClient(baseURL, token, userID, user, password string) *Client

NewEmbyClient returns a Client configured for an Emby server.

func NewJellyfinClient

func NewJellyfinClient(baseURL, token, userID, user, password string) *Client

NewJellyfinClient returns a Client configured for a Jellyfin server.

func (*Client) AlbumList

func (c *Client) AlbumList(sortType string, offset, size int) ([]provider.AlbumInfo, error)

AlbumList returns one page from the full album catalog, sorted client-side.

func (*Client) AlbumSortTypes

func (c *Client) AlbumSortTypes() []provider.SortType

func (*Client) Albums

func (c *Client) Albums() ([]Album, error)

Albums returns all albums across every music library. Results are cached after the first successful call.

func (*Client) AlbumsByLibrary

func (c *Client) AlbumsByLibrary(libraryID string) ([]Album, error)

AlbumsByLibrary returns all albums under one music library view.

func (*Client) ArtistAlbums

func (c *Client) ArtistAlbums(artistID string) ([]provider.AlbumInfo, error)

ArtistAlbums returns all albums for one artist, derived from the full album list.

func (*Client) Artists

func (c *Client) Artists() ([]provider.ArtistInfo, error)

Artists returns a derived artist list built from the server's album catalog.

func (*Client) ClearCache

func (c *Client) ClearCache()

ClearCache discards the cached album list so the next Albums call re-fetches.

func (*Client) DefaultAlbumSort

func (c *Client) DefaultAlbumSort() string

func (*Client) MetaKey

func (c *Client) MetaKey() string

MetaKey returns the playlist.Track ProviderMeta key for this server's item IDs.

func (*Client) MusicLibraries

func (c *Client) MusicLibraries() ([]Library, error)

MusicLibraries returns all user views whose collection type is music.

func (*Client) Ping

func (c *Client) Ping() error

Ping checks that the server is reachable and the token is accepted.

func (*Client) ReportNowPlaying

func (c *Client) ReportNowPlaying(track playlist.Track, position time.Duration, canSeek bool) error

func (*Client) ReportScrobble

func (c *Client) ReportScrobble(track playlist.Track, elapsed time.Duration, canSeek bool) error

func (*Client) Search

func (c *Client) Search(query string, limit int) ([]Track, error)

Search searches the user's audio library for tracks matching query and returns up to limit results.

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(hc *http.Client)

SetHTTPClient overrides the HTTP client used for requests. Mainly for tests that inject a custom transport.

func (*Client) StreamURL

func (c *Client) StreamURL(itemID string) string

StreamURL returns an authenticated audio URL for a track item.

func (*Client) Tracks

func (c *Client) Tracks(albumID string) ([]Track, error)

Tracks returns all audio tracks contained by an album item.

func (*Client) UserID

func (c *Client) UserID() (string, error)

UserID returns the active user id, discovering it lazily when needed.

type Library

type Library struct {
	ID   string
	Name string
}

Library represents a music library view.

type Track

type Track struct {
	ID           string
	Name         string
	Artist       string
	Album        string
	Year         int
	TrackNumber  int
	DurationSecs int
}

Track represents a track entry.

Jump to

Keyboard shortcuts

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