🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Implemented more getAlbumList.view types
Deluan1c9d7721ad92
diff --git a/api/get_album_list.go b/api/get_album_list.goindex d3dafc170..885d11ece 100644--- a/api/get_album_list.go+++ b/api/get_album_list.go@@ -18,9 +18,11 @@ type GetAlbumListController struct {func (c *GetAlbumListController) Prepare() {inject.ExtractAssignable(utils.Graph, &c.albumRepo)- // TODO To implement other types, we need to fix album data at import timec.types = map[string]domain.QueryOptions{- "newest": domain.QueryOptions{SortBy: "CreatedAt", Desc: true, Alpha: true},+ "newest": domain.QueryOptions{SortBy: "CreatedAt", Desc: true, Alpha: true},+ "recent": domain.QueryOptions{SortBy: "PlayDate", Desc: true, Alpha: true},+ "frequent": domain.QueryOptions{SortBy: "PlayCount", Desc: true},+ "highest": domain.QueryOptions{SortBy: "Rating", Desc: true},}}diff --git a/domain/album.go b/domain/album.goindex 0f14560a8..12b43fc6a 100644--- a/domain/album.go+++ b/domain/album.go@@ -13,6 +13,8 @@ type Album struct {Year intCompilation boolStarred bool+ PlayCount int+ PlayDate time.TimeRating intGenre stringCreatedAt time.Timediff --git a/domain/mediafile.go b/domain/mediafile.goindex 658e88ad4..32442d18b 100644--- a/domain/mediafile.go+++ b/domain/mediafile.go@@ -1,8 +1,8 @@package domainimport (- "time""mime"+ "time")type MediaFile struct {@@ -23,6 +23,9 @@ type MediaFile struct {BitRate intGenre stringCompilation bool+ PlayCount int+ PlayDate time.Time+ Rating intStarred boolCreatedAt time.TimeUpdatedAt time.Time@@ -33,10 +36,11 @@ func (mf *MediaFile) ContentType() string {}type MediaFiles []MediaFile-func (a MediaFiles) Len() int { return len(a) }++func (a MediaFiles) Len() int { return len(a) }func (a MediaFiles) Swap(i, j int) { a[i], a[j] = a[j], a[i] }func (a MediaFiles) Less(i, j int) bool {- return (a[i].DiscNumber * 1000 + a[i].TrackNumber) < (a[j].DiscNumber * 1000 + a[j].TrackNumber)+ return (a[i].DiscNumber*1000 + a[i].TrackNumber) < (a[j].DiscNumber*1000 + a[j].TrackNumber)}type MediaFileRepository interface {diff --git a/scanner/itunes_scanner.go b/scanner/itunes_scanner.goindex 139264fd3..90a7d0ce5 100644--- a/scanner/itunes_scanner.go+++ b/scanner/itunes_scanner.go@@ -64,6 +64,9 @@ func (s *ItunesScanner) collectMediaFiles(t *itl.Track) *domain.MediaFile {mf.Genre = unescape(t.Genre)mf.Compilation = t.Compilationmf.Starred = t.Loved+ mf.Rating = t.Rating+ mf.PlayCount = t.PlayCount+ mf.PlayDate = t.PlayDateUTCmf.Year = t.Yearmf.TrackNumber = t.TrackNumbermf.DiscNumber = t.DiscNumber@@ -103,6 +106,8 @@ func (s *ItunesScanner) collectAlbums(t *itl.Track, mf *domain.MediaFile, ar *doal.Year = t.Yearal.Compilation = t.Compilational.Starred = t.AlbumLoved+ al.Rating = t.AlbumRating+ al.PlayCount += t.PlayCountal.Genre = mf.Genreal.Artist = mf.Artistal.AlbumArtist = mf.AlbumArtist@@ -111,6 +116,9 @@ func (s *ItunesScanner) collectAlbums(t *itl.Track, mf *domain.MediaFile, ar *doal.CoverArtId = mf.Id}+ if al.PlayDate.IsZero() || t.PlayDateUTC.After(al.PlayDate) {+ al.PlayDate = t.PlayDateUTC+ }if al.CreatedAt.IsZero() || t.DateAdded.Before(al.CreatedAt) {al.CreatedAt = t.DateAdded}