mediaprovider

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAlbumFilter added in v0.10.0

func NewAlbumFilter(options AlbumFilterOptions) *albumFilter

func NewArtistFilter added in v0.10.0

func NewArtistFilter(options ArtistFilterOptions) *artistFilter

Types

type Album

type Album struct {
	ID           string
	CoverArtID   string
	Name         string
	Duration     int
	ArtistIDs    []string
	ArtistNames  []string
	Year         int
	ReissueYear  int
	Genres       []string
	TrackCount   int
	Favorite     bool
	ReleaseTypes ReleaseTypes
}

type AlbumFilter

type AlbumFilter = MediaFilter[Album, AlbumFilterOptions]

type AlbumFilterOptions added in v0.10.0

type AlbumFilterOptions struct {
	MinYear int
	MaxYear int      // 0 == unset/match any
	Genres  []string // len(0) == unset/match any

	ExcludeFavorited   bool // mut. exc. with ExcludeUnfavorited
	ExcludeUnfavorited bool // mut. exc. with ExcludeFavorited
}

func (AlbumFilterOptions) Clone added in v0.10.0

Clone returns a deep copy of the filter options

type AlbumInfo added in v0.5.0

type AlbumInfo struct {
	Notes         string
	LastFmUrl     string
	MusicBrainzID string
}

type AlbumIterator

type AlbumIterator = MediaIterator[Album]

type AlbumWithTracks

type AlbumWithTracks struct {
	Album
	Tracks []*Track
}

type Artist

type Artist struct {
	ID         string
	CoverArtID string
	Name       string
	Favorite   bool
	AlbumCount int
}

type ArtistFilter added in v0.10.0

type ArtistFilter = MediaFilter[Artist, ArtistFilterOptions]

type ArtistFilterOptions added in v0.10.0

type ArtistFilterOptions struct {
	SearchQuery string
}

func (ArtistFilterOptions) Clone added in v0.10.0

Clone returns a deep copy of the filter options

type ArtistInfo

type ArtistInfo struct {
	Biography      string
	LastFMUrl      string
	ImageURL       string
	SimilarArtists []*Artist
}

type ArtistIterator added in v0.10.0

type ArtistIterator = MediaIterator[Artist]

type ArtistWithAlbums

type ArtistWithAlbums struct {
	Artist
	Albums []*Album
}

type CanSavePlayQueue added in v0.10.0

type CanSavePlayQueue interface {
	SavePlayQueue(trackIDs []string, currentTrackPos int, timeSeconds int) error
	GetPlayQueue() (*SavedPlayQueue, error)
}

type ContentType added in v0.7.0

type ContentType int
const (
	ContentTypeAlbum ContentType = iota
	ContentTypeArtist
	ContentTypePlaylist
	ContentTypeTrack
	ContentTypeGenre
)

func (ContentType) String added in v0.7.0

func (c ContentType) String() string

type Favorites

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

type Genre

type Genre struct {
	Name       string
	AlbumCount int
	TrackCount int
}

type JukeboxProvider added in v0.9.0

type JukeboxProvider interface {
	JukeboxStart() error
	JukeboxStop() error
	JukeboxSeek(idx, seconds int) error
	JukeboxClear() error
	JukeboxSet(trackID string) error
	JukeboxAdd(trackID string) error
	JukeboxRemove(idx int) error
	JukeboxSetVolume(vol int) error
	JukeboxGetStatus() (*JukeboxStatus, error)
}

type JukeboxStatus added in v0.9.0

type JukeboxStatus struct {
	Volume          int
	CurrentTrack    int
	Playing         bool
	PositionSeconds float64
}

type LoginResponse added in v0.8.0

type LoginResponse struct {
	Error       error
	IsAuthError bool
}

type LyricLine added in v0.10.0

type LyricLine struct {
	Text  string
	Start float64 // seconds
}

type Lyrics added in v0.10.0

type Lyrics struct {
	Title  string
	Artist string
	Synced bool
	Lines  []LyricLine
}

type LyricsProvider added in v0.10.0

type LyricsProvider interface {
	GetLyrics(track *Track) (*Lyrics, error)
}

type MediaFilter added in v0.10.0

type MediaFilter[M, F any] interface {
	Options() F
	SetOptions(F)
	Clone() MediaFilter[M, F]
	IsNil() bool
	Matches(*M) bool
}

type MediaIterator added in v0.10.0

type MediaIterator[M any] interface {
	Next() *M
}

type MediaProvider

type MediaProvider interface {
	SetPrefetchCoverCallback(cb func(coverArtID string))

	GetTrack(trackID string) (*Track, error)

	GetAlbum(albumID string) (*AlbumWithTracks, error)

	GetAlbumInfo(albumID string) (*AlbumInfo, error)

	GetArtist(artistID string) (*ArtistWithAlbums, error)

	GetArtistInfo(artistID string) (*ArtistInfo, error)

	GetPlaylist(playlistID string) (*PlaylistWithTracks, error)

	GetCoverArt(coverArtID string, size int) (image.Image, error)

	AlbumSortOrders() []string

	IterateAlbums(sortOrder string, filter AlbumFilter) AlbumIterator

	IterateTracks(searchQuery string) TrackIterator

	SearchAlbums(searchQuery string, filter AlbumFilter) AlbumIterator

	SearchAll(searchQuery string, maxResults int) ([]*SearchResult, error)

	GetRandomTracks(genre string, count int) ([]*Track, error)

	GetSimilarTracks(artistID string, count int) ([]*Track, error)

	GetSongRadio(trackID string, count int) ([]*Track, error)

	ArtistSortOrders() []string

	IterateArtists(sortOrder string, filter ArtistFilter) ArtistIterator

	SearchArtists(searchQuery string, filter ArtistFilter) ArtistIterator

	GetGenres() ([]*Genre, error)

	GetFavorites() (Favorites, error)

	GetStreamURL(trackID string, forceRaw bool) (string, error)

	GetTopTracks(artist Artist, count int) ([]*Track, error)

	SetFavorite(params RatingFavoriteParameters, favorite bool) error

	GetPlaylists() ([]*Playlist, error)

	CreatePlaylist(name string, trackIDs []string) error

	CanMakePublicPlaylist() bool

	EditPlaylist(id, name, description string, public bool) error

	AddPlaylistTracks(id string, trackIDsToAdd []string) error

	RemovePlaylistTracks(id string, trackIdxsToRemove []int) error

	ReplacePlaylistTracks(id string, trackIDs []string) error

	DeletePlaylist(id string) error

	// True if the `submission` parameter to TrackEndedPlayback will be respected
	// If false, the begin playback scrobble registers a play count immediately
	// when TrackBeganPlayback is invoked.
	ClientDecidesScrobble() bool

	TrackBeganPlayback(trackID string) error

	TrackEndedPlayback(trackID string, positionSecs int, submission bool) error

	DownloadTrack(trackID string) (io.Reader, error)

	RescanLibrary() error
}

type Playlist

type Playlist struct {
	ID          string
	CoverArtID  string
	Name        string
	Description string
	Public      bool
	Owner       string
	Duration    int
	TrackCount  int
}

type PlaylistWithTracks

type PlaylistWithTracks struct {
	Playlist
	Tracks []*Track
}

type RatingFavoriteParameters

type RatingFavoriteParameters struct {
	AlbumIDs  []string
	ArtistIDs []string
	TrackIDs  []string
}

type ReleaseType added in v0.9.0

type ReleaseType = int32

Bit field flag for the ReleaseTypes property

const (
	ReleaseTypeAlbum          ReleaseType = 0x0001
	ReleaseTypeAudiobook      ReleaseType = 0x0002
	ReleaseTypeAudioDrama     ReleaseType = 0x0004
	ReleaseTypeBroadcast      ReleaseType = 0x0008
	ReleaseTypeCompilation    ReleaseType = 0x0010
	ReleaseTypeDemo           ReleaseType = 0x0020
	ReleaseTypeDJMix          ReleaseType = 0x0040
	ReleaseTypeEP             ReleaseType = 0x0080
	ReleaseTypeFieldRecording ReleaseType = 0x0100
	ReleaseTypeInterview      ReleaseType = 0x0200
	ReleaseTypeLive           ReleaseType = 0x0400
	ReleaseTypeMixtape        ReleaseType = 0x0800
	ReleaseTypeRemix          ReleaseType = 0x1000
	ReleaseTypeSingle         ReleaseType = 0x2000
	ReleaseTypeSoundtrack     ReleaseType = 0x4000
	ReleaseTypeSpokenWord     ReleaseType = 0x8000
)

Set of possible release types Taken from Picard:

(a) https://picard-docs.musicbrainz.org/en/config/options_releases.html
(b) https://musicbrainz.org/doc/Release_Group/Type

type ReleaseTypes added in v0.9.0

type ReleaseTypes = int32

Bit field of release types

type SavedPlayQueue added in v0.10.0

type SavedPlayQueue struct {
	Tracks   []*Track
	TrackPos int
	TimePos  int // seconds
}

type SearchResult added in v0.7.0

type SearchResult struct {
	Name    string
	ID      string
	CoverID string
	Type    ContentType

	// for Album / Playlist: track count
	//     Artist / Genre: album count
	//     Track: length (seconds)
	Size int

	// Unset for ContentTypes Artist, Playlist, and Genre
	ArtistName string
}

type Server added in v0.8.0

type Server interface {
	Login(username, password string) LoginResponse
	MediaProvider() MediaProvider
}

type SupportsRating added in v0.8.0

type SupportsRating interface {
	SetRating(params RatingFavoriteParameters, rating int) error
}

type SupportsSharing added in v0.10.0

type SupportsSharing interface {
	CreateShareURL(id string) (*url.URL, error)
	CanShareArtists() bool
}

type Track

type Track struct {
	ID          string
	CoverArtID  string
	ParentID    string
	Name        string
	Duration    int
	TrackNumber int
	DiscNumber  int
	Genre       string
	ArtistIDs   []string
	ArtistNames []string
	Album       string
	AlbumID     string
	Year        int
	Rating      int
	Favorite    bool
	Size        int64
	PlayCount   int
	FilePath    string
	BitRate     int
	Comment     string
}

type TrackIterator

type TrackIterator = MediaIterator[Track]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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