Files
supersonic/backend/mediaprovider/mediaprovider.go
T
natilou f190aaf732 Ability to download tracks
- Adding the option to download the selected track or tracks.
When the download is clicked it opens a dialog that lets you choose where
you want to save the track and the file name (by default
the file name is the track number, the track name and the extension, example "03 - my song.mp3")
If there are many tracks selected it will open one dialog for each track
- Next steps: download an album and a playlist using zip
2023-06-15 10:12:53 -03:00

92 lines
2.0 KiB
Go

package mediaprovider
import (
"image"
"io"
)
type AlbumFilter 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
}
type AlbumIterator interface {
Next() *Album
}
type TrackIterator interface {
Next() *Track
}
type RatingFavoriteParameters struct {
AlbumIDs []string
ArtistIDs []string
TrackIDs []string
}
type Favorites struct {
Albums []*Album
Artists []*Artist
Tracks []*Track
}
type MediaProvider interface {
SetPrefetchCoverCallback(cb func(coverArtID string))
GetAlbum(albumID string) (*AlbumWithTracks, 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
GetRandomTracks(genre string, count int) ([]*Track, error)
GetSimilarTracks(artistID string, count int) ([]*Track, error)
GetArtists() ([]*Artist, error)
GetGenres() ([]*Genre, error)
GetFavorites() (Favorites, error)
GetStreamURL(trackID string) (string, error)
GetTopTracks(artist Artist, count int) ([]*Track, error)
SetFavorite(params RatingFavoriteParameters, favorite bool) error
SetRating(params RatingFavoriteParameters, rating int) error
GetPlaylists() ([]*Playlist, error)
CreatePlaylist(name string, trackIDs []string) error
EditPlaylist(id, name, description string, public bool) error
EditPlaylistTracks(id string, trackIDsToAdd []string, trackIndexesToRemove []int) error
ReplacePlaylistTracks(id string, trackIDs []string) error
DeletePlaylist(id string) error
Scrobble(trackID string, submission bool) error
DownloadTrack(trackID string) (io.Reader, error)
}