Skip to content

🎧 Your Personal Streaming Service

Implemented more getAlbumList.view types

Deluan1c9d7721ad92
diff --git a/api/get_album_list.go b/api/get_album_list.go
index 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 time
c.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.go
index 0f14560a8..12b43fc6a 100644
--- a/domain/album.go
+++ b/domain/album.go
@@ -13,6 +13,8 @@ type Album struct {
Year int
Compilation bool
Starred bool
+ PlayCount int
+ PlayDate time.Time
Rating int
Genre string
CreatedAt time.Time
diff --git a/domain/mediafile.go b/domain/mediafile.go
index 658e88ad4..32442d18b 100644
--- a/domain/mediafile.go
+++ b/domain/mediafile.go
@@ -1,8 +1,8 @@
package domain
import (
- "time"
"mime"
+ "time"
)
type MediaFile struct {
@@ -23,6 +23,9 @@ type MediaFile struct {
BitRate int
Genre string
Compilation bool
+ PlayCount int
+ PlayDate time.Time
+ Rating int
Starred bool
CreatedAt time.Time
UpdatedAt 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.go
index 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.Compilation
mf.Starred = t.Loved
+ mf.Rating = t.Rating
+ mf.PlayCount = t.PlayCount
+ mf.PlayDate = t.PlayDateUTC
mf.Year = t.Year
mf.TrackNumber = t.TrackNumber
mf.DiscNumber = t.DiscNumber
@@ -103,6 +106,8 @@ func (s *ItunesScanner) collectAlbums(t *itl.Track, mf *domain.MediaFile, ar *do
al.Year = t.Year
al.Compilation = t.Compilation
al.Starred = t.AlbumLoved
+ al.Rating = t.AlbumRating
+ al.PlayCount += t.PlayCount
al.Genre = mf.Genre
al.Artist = mf.Artist
al.AlbumArtist = mf.AlbumArtist
@@ -111,6 +116,9 @@ func (s *ItunesScanner) collectAlbums(t *itl.Track, mf *domain.MediaFile, ar *do
al.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
}