mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-16 12:10:36 +03:00
Implemented more getAlbumList.view types
This commit is contained in:
parent
766fdbc60c
commit
1c9d7721ad
@ -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},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user