mediaprovider

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// set of all supported album sorts across all media providers
	// these strings may be translated
	AlbumSortRecentlyAdded    string = "Recently Added"
	AlbumSortRecentlyPlayed   string = "Recently Played"
	AlbumSortFrequentlyPlayed string = "Frequently Played"
	AlbumSortRandom           string = "Random"
	AlbumSortTitleAZ          string = "Title (A-Z)"
	AlbumSortArtistAZ         string = "Artist (A-Z)"
	AlbumSortYearAscending    string = "Year (ascending)"
	AlbumSortYearDescending   string = "Year (descending)"

	// set of all supported artist sorts across all media providers
	// these strings may be translated
	ArtistSortAlbumCount string = "Album Count"
	ArtistSortNameAZ     string = "Name (A-Z)"
	ArtistSortRandom     string = "Random"
)

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

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 MediaItem added in v0.11.0

type MediaItem interface {
	Metadata() MediaItemMetadata
	Copy() MediaItem
}

type MediaItemMetadata added in v0.11.0

type MediaItemMetadata struct {
	Type       MediaItemType
	ID         string
	Name       string
	Artists    []string
	ArtistIDs  []string
	Album      string
	AlbumID    string
	CoverArtID string
	Duration   int
}

type MediaItemType added in v0.11.0

type MediaItemType int
const (
	MediaItemTypeTrack MediaItemType = iota
	MediaItemTypeRadioStation
)

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)

	GetArtistTracks(artistID string) ([]*Track, 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 RadioProvider added in v0.11.0

type RadioProvider interface {
	GetRadioStation(id string) (*RadioStation, error)
	GetRadioStations() ([]*RadioStation, error)
}

type RadioStation added in v0.11.0

type RadioStation struct {
	Name        string
	ID          string
	HomePageURL string
	StreamURL   string
}

func (*RadioStation) Copy added in v0.11.0

func (r *RadioStation) Copy() MediaItem

func (*RadioStation) Metadata added in v0.11.0

func (r *RadioStation) Metadata() MediaItemMetadata

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 ReplayGainInfo added in v0.13.0

type ReplayGainInfo struct {
	TrackGain float64
	AlbumGain float64
	TrackPeak float64
	AlbumPeak float64
}

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)
	// for Radio: none
	Size int

	// Unset for ContentTypes Artist, Playlist, Genre, and RadioStation
	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
	Title         string
	Duration      int
	TrackNumber   int
	DiscNumber    int
	Genres        []string
	ArtistIDs     []string
	ArtistNames   []string
	ComposerIDs   []string
	ComposerNames []string
	Album         string
	AlbumID       string
	Year          int
	Rating        int
	Favorite      bool
	Size          int64
	PlayCount     int
	LastPlayed    time.Time
	FilePath      string
	BitRate       int
	ContentType   string
	Comment       string
	BPM           int
	ReplayGain    ReplayGainInfo
}

func (*Track) Copy added in v0.11.0

func (t *Track) Copy() MediaItem

func (*Track) Metadata added in v0.11.0

func (t *Track) Metadata() MediaItemMetadata

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