library

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 4 Imported by: 0 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 library is the seam between the player and a music server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Album

type Album struct {
	ID, Title, Artist, ArtistID string
	Year, TrackCount            int
	AddedAt                     int64
	Server                      string // which server the album lives on
}

type Artist

type Artist struct{ ID, Name, Server string }

type Letter

type Letter struct {
	Letter string
	Count  int
}

Letter is one entry of the artist index: how many artists sort under it.

type Library

type Library interface {
	Search(ctx context.Context, query string) (SearchResult, error)
	RecentAlbums(ctx context.Context, offset, limit int) ([]Album, error)
	AlbumTracks(ctx context.Context, albumID string) ([]Track, error)
	ArtistAlbums(ctx context.Context, artistID string) ([]Album, error)
	// Artists returns a page of all artists in sort order and the total count.
	Artists(ctx context.Context, offset, limit int) ([]Artist, int, error)
	// ArtistIndex returns the first letters artists sort under, in sort order.
	ArtistIndex(ctx context.Context) ([]Letter, error)
	// Playlists lists the user's playlists in the server's order.
	Playlists(ctx context.Context) ([]Playlist, error)
	// PlaylistTracks returns a playlist's tracks in playlist order.
	PlaylistTracks(ctx context.Context, playlistID string) ([]Track, error)
	// CreatePlaylist makes a new playlist holding tracks, in order, and
	// returns it. Every track must belong to this library.
	CreatePlaylist(ctx context.Context, name string, tracks []Track) (Playlist, error)
	// AddToPlaylist appends tracks, in order, to the playlist.
	AddToPlaylist(ctx context.Context, playlistID string, tracks []Track) error
	// RemoveFromPlaylist drops the entry at position index (0-based).
	RemoveFromPlaylist(ctx context.Context, playlistID string, index int) error
	// MovePlaylistTrack moves the entry at from so it sits at position to.
	MovePlaylistTrack(ctx context.Context, playlistID string, from, to int) error
	// RenamePlaylist gives the playlist a new name.
	RenamePlaylist(ctx context.Context, playlistID, name string) error
	// DeletePlaylist removes the playlist from the server.
	DeletePlaylist(ctx context.Context, playlistID string) error
	Stream(ctx context.Context, t Track) (Stream, error)
}

type Playlist added in v0.9.0

type Playlist struct {
	ID, Name   string
	TrackCount int
	Server     string // which server it lives on
}

Playlist is one of the user's playlists on a server.

type Saved added in v0.9.0

type Saved struct {
	Server   string // server ID
	Playlist Playlist
	Tracks   int
}

Saved is one server's share of a saved queue.

type SearchResult

type SearchResult struct {
	Artists []Artist
	Albums  []Album
	Tracks  []Track
}

type Similar added in v0.19.0

type Similar interface {
	Similar(ctx context.Context, t Track, n int) ([]Track, error)
}

Similar is implemented by libraries that can suggest tracks like t.

type Stream

type Stream struct {
	URL     string
	Codec   string // codec of the bytes at URL: "flac" or "mp3"
	Headers map[string]string
}

type Track

type Track struct {
	ID, Title, Artist, Album, AlbumID string
	Index                             int
	Duration                          time.Duration
	Codec                             string // "flac", "mp3", "aac"
	Container                         string
	PartKey                           string // server-relative path of the media file, e.g. /library/parts/1/1/file.flac
	Bitrate, SampleRate, BitDepth     int
	Server                            string // which server the track lives on
}

func (Track) Quality added in v0.9.2

func (t Track) Quality() string

Quality is a short label for the track's format, the kind a player prints beside an album so two copies at different quality read apart: "FLAC 16/44.1", "FLAC 24/96", "MP3 320k", "AAC 256k". Lossless codecs show bit depth and sample rate; lossy ones show the bitrate. Empty when the codec is unknown.

Jump to

Keyboard shortcuts

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