diff --git a/backend/mediaprovider/mediaprovider.go b/backend/mediaprovider/mediaprovider.go new file mode 100644 index 0000000..a8e61c2 --- /dev/null +++ b/backend/mediaprovider/mediaprovider.go @@ -0,0 +1,64 @@ +package mediaprovider + +import "image" + +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 { + GetAlbum(albumID string) (*AlbumWithTracks, error) + + GetArtist(artistID string) (*Artist, error) + + GetPlaylist(playlistID string) (*PlaylistWithTracks, error) + + GetCoverArt(coverArtID string, size int) (image.Image, error) + + AlbumSortOrders() []string + + IterateAlbums(sortOrder string, searchQuery string, filter AlbumFilter) AlbumIterator + + IterateTracks(searchQuery string) TrackIterator + + GetRandomTracks(genre string, count int) ([]Track, error) + + GetSimilarTracks(artistID string, count int) ([]Track, error) + + GetArtists() ([]Artist, error) + + GetGenres() ([]Genre, error) + + GetFavorites() (Favorites, error) + + GetPlaylists() ([]Playlist, error) + + SetFavorite(params RatingFavoriteParameters) error + + SetRating(params RatingFavoriteParameters) error +} diff --git a/backend/mediaprovider/model.go b/backend/mediaprovider/model.go new file mode 100644 index 0000000..64f7a50 --- /dev/null +++ b/backend/mediaprovider/model.go @@ -0,0 +1,61 @@ +package mediaprovider + +type Album struct { + ID string + CoverArtID string + Name string + Duration int + ArtistIDs []string + ArtistNames []string + Year int + Genres []string + TrackCount int + Favorite bool +} + +type AlbumWithTracks struct { + Album + Tracks []Track +} + +type Artist struct { + ID string + Name string + Albums []Album +} + +type Genre struct { + Name string + AlbumCount int + TrackCount int +} + +type Track struct { + ID string + CoverArtID string + ParentID string + Name string + Duration int + Genre string + ArtistIDs []string + ArtistNames []string + Rating int + Favorite bool + Size int64 + PlayCount int64 + FilePath string +} + +type Playlist struct { + ID string + CoverArtID string + Name string + Description string + Public bool + Owner string +} + +type PlaylistWithTracks struct { + Playlist + Tracks []Track +}