more refactoring - compiles now but not extensively tested
This commit is contained in:
+3
-5
@@ -25,7 +25,6 @@ type App struct {
|
||||
Config *Config
|
||||
ServerManager *ServerManager
|
||||
ImageManager *ImageManager
|
||||
LibraryManager *LibraryManager
|
||||
PlaybackManager *PlaybackManager
|
||||
Player *player.Player
|
||||
UpdateChecker UpdateChecker
|
||||
@@ -63,11 +62,10 @@ func StartupApp(appName, appVersionTag, configFile, latestReleaseURL string) (*A
|
||||
|
||||
a.ServerManager = NewServerManager(appName)
|
||||
a.PlaybackManager = NewPlaybackManager(a.bgrndCtx, a.ServerManager, a.Player, &a.Config.Scrobbling)
|
||||
a.LibraryManager = NewLibraryManager(a.ServerManager)
|
||||
a.ImageManager = NewImageManager(a.bgrndCtx, a.ServerManager, configdir.LocalCache(a.appName))
|
||||
a.LibraryManager.PreCacheCoverFn = func(coverID string) {
|
||||
_, _ = a.ImageManager.GetCoverThumbnail(coverID)
|
||||
}
|
||||
//a.LibraryManager.PreCacheCoverFn = func(coverID string) {
|
||||
//_, _ = a.ImageManager.GetCoverThumbnail(coverID)
|
||||
//}
|
||||
|
||||
return a, nil
|
||||
}
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ func DefaultConfig(appVersionTag string) *Config {
|
||||
TracklistColumns: []string{"Artist", "Time", "Plays", "Favorite", "Rating"},
|
||||
},
|
||||
AlbumsPage: AlbumsPageConfig{
|
||||
SortOrder: string(AlbumSortRecentlyAdded),
|
||||
SortOrder: string("Recently Added"),
|
||||
},
|
||||
ArtistPage: ArtistPageConfig{
|
||||
InitialView: "Discography",
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package backend
|
||||
|
||||
import (
|
||||
subsonic "github.com/dweymouth/go-subsonic/subsonic"
|
||||
)
|
||||
|
||||
type AlbumIterator interface {
|
||||
Next() *subsonic.AlbumID3
|
||||
}
|
||||
|
||||
type TrackIterator interface {
|
||||
Next() *subsonic.Child
|
||||
}
|
||||
|
||||
type LibraryManager struct {
|
||||
PreCacheCoverFn func(coverID string)
|
||||
|
||||
s *ServerManager
|
||||
}
|
||||
|
||||
func NewLibraryManager(s *ServerManager) *LibraryManager {
|
||||
return &LibraryManager{
|
||||
s: s,
|
||||
}
|
||||
}
|
||||
@@ -60,11 +60,13 @@ type MediaProvider interface {
|
||||
|
||||
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)
|
||||
GetPlaylists() ([]*Playlist, error)
|
||||
|
||||
CreatePlaylist(name string, trackIDs []string) error
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ type AlbumWithTracks struct {
|
||||
type Artist struct {
|
||||
ID string
|
||||
Name string
|
||||
Favorite bool
|
||||
AlbumCount int
|
||||
}
|
||||
|
||||
@@ -71,6 +72,7 @@ type Playlist struct {
|
||||
Description string
|
||||
Public bool
|
||||
Owner string
|
||||
Duration int
|
||||
TrackCount int
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ func (s *subsonicMediaProvider) GetArtist(artistID string) (*mediaprovider.Artis
|
||||
Artist: mediaprovider.Artist{
|
||||
ID: ar.ID,
|
||||
Name: ar.Name,
|
||||
Favorite: !ar.Starred.IsZero(),
|
||||
AlbumCount: ar.AlbumCount,
|
||||
},
|
||||
Albums: sharedutil.MapSlice(ar.Album, toAlbum),
|
||||
@@ -168,12 +169,21 @@ func (s *subsonicMediaProvider) GetPlaylist(playlistID string) (*mediaprovider.P
|
||||
return nil, err
|
||||
}
|
||||
return &mediaprovider.PlaylistWithTracks{
|
||||
Playlist: toPlaylist(pl),
|
||||
Tracks: sharedutil.MapSlice(pl.Entry, toTrack),
|
||||
Playlist: mediaprovider.Playlist{
|
||||
ID: pl.ID,
|
||||
CoverArtID: pl.CoverArt,
|
||||
Name: pl.Name,
|
||||
Description: pl.Comment,
|
||||
TrackCount: pl.SongCount,
|
||||
Public: pl.Public,
|
||||
Owner: pl.Owner,
|
||||
Duration: pl.Duration,
|
||||
},
|
||||
Tracks: sharedutil.MapSlice(pl.Entry, toTrack),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *subsonicMediaProvider) GetPlaylists() ([]mediaprovider.Playlist, error) {
|
||||
func (s *subsonicMediaProvider) GetPlaylists() ([]*mediaprovider.Playlist, error) {
|
||||
pl, err := s.client.GetPlaylists(map[string]string{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -209,6 +219,18 @@ func (s *subsonicMediaProvider) GetStreamURL(trackID string) (string, error) {
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
func (s *subsonicMediaProvider) GetTopTracks(artist mediaprovider.Artist, count int) ([]*mediaprovider.Track, error) {
|
||||
params := map[string]string{}
|
||||
if count > 0 {
|
||||
params["count"] = strconv.Itoa(count)
|
||||
}
|
||||
tr, err := s.client.GetTopSongs(artist.Name, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sharedutil.MapSlice(tr, toTrack), nil
|
||||
}
|
||||
|
||||
func (s *subsonicMediaProvider) ReplacePlaylistTracks(playlistID string, trackIDs []string) error {
|
||||
return s.client.CreatePlaylistWithTracks(trackIDs, map[string]string{"playlistId": playlistID})
|
||||
}
|
||||
@@ -319,8 +341,9 @@ func toArtist(ar *subsonic.Artist) *mediaprovider.Artist {
|
||||
return nil
|
||||
}
|
||||
return &mediaprovider.Artist{
|
||||
ID: ar.ID,
|
||||
Name: ar.Name,
|
||||
ID: ar.ID,
|
||||
Name: ar.Name,
|
||||
Favorite: !ar.Starred.IsZero(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,16 +354,20 @@ func toArtistFromID3(ar *subsonic.ArtistID3) *mediaprovider.Artist {
|
||||
return &mediaprovider.Artist{
|
||||
ID: ar.ID,
|
||||
Name: ar.Name,
|
||||
Favorite: !ar.Starred.IsZero(),
|
||||
AlbumCount: ar.AlbumCount,
|
||||
}
|
||||
}
|
||||
|
||||
func toPlaylist(pl *subsonic.Playlist) mediaprovider.Playlist {
|
||||
return mediaprovider.Playlist{
|
||||
func toPlaylist(pl *subsonic.Playlist) *mediaprovider.Playlist {
|
||||
return &mediaprovider.Playlist{
|
||||
Name: pl.Name,
|
||||
ID: pl.ID,
|
||||
CoverArtID: pl.CoverArt,
|
||||
Description: pl.Comment,
|
||||
Owner: pl.Owner,
|
||||
Public: pl.Public,
|
||||
TrackCount: pl.SongCount,
|
||||
Duration: pl.Duration,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user