mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-16 04:00:38 +03:00
More Album List types
This commit is contained in:
parent
5dd4b15079
commit
12b1002d51
@ -19,11 +19,14 @@ func (c *AlbumListController) Prepare() {
|
||||
utils.ResolveDependencies(&c.listGen)
|
||||
|
||||
c.types = map[string]strategy{
|
||||
"random": func(o int, s int) (engine.Entries, error) { return c.listGen.GetRandom(o, s) },
|
||||
"newest": func(o int, s int) (engine.Entries, error) { return c.listGen.GetNewest(o, s) },
|
||||
"recent": func(o int, s int) (engine.Entries, error) { return c.listGen.GetRecent(o, s) },
|
||||
"frequent": func(o int, s int) (engine.Entries, error) { return c.listGen.GetFrequent(o, s) },
|
||||
"highest": func(o int, s int) (engine.Entries, error) { return c.listGen.GetHighest(o, s) },
|
||||
"random": func(o int, s int) (engine.Entries, error) { return c.listGen.GetRandom(o, s) },
|
||||
"newest": func(o int, s int) (engine.Entries, error) { return c.listGen.GetNewest(o, s) },
|
||||
"recent": func(o int, s int) (engine.Entries, error) { return c.listGen.GetRecent(o, s) },
|
||||
"frequent": func(o int, s int) (engine.Entries, error) { return c.listGen.GetFrequent(o, s) },
|
||||
"highest": func(o int, s int) (engine.Entries, error) { return c.listGen.GetHighest(o, s) },
|
||||
"alphabeticalByName": func(o int, s int) (engine.Entries, error) { return c.listGen.GetByName(o, s) },
|
||||
"alphabeticalByArtist": func(o int, s int) (engine.Entries, error) { return c.listGen.GetByArtist(o, s) },
|
||||
"starred": func(o int, s int) (engine.Entries, error) { return c.listGen.GetStarred(o, s) },
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,7 +54,7 @@ func (c *AlbumListController) GetAlbumList() {
|
||||
}
|
||||
|
||||
func (c *AlbumListController) GetStarred() {
|
||||
albums, err := c.listGen.GetStarred()
|
||||
albums, err := c.listGen.GetStarred(0, -1)
|
||||
if err != nil {
|
||||
beego.Error("Error retrieving starred albums:", err)
|
||||
c.SendError(responses.ERROR_GENERIC, "Internal Error")
|
@ -14,7 +14,9 @@ type ListGenerator interface {
|
||||
GetFrequent(offset int, size int) (Entries, error)
|
||||
GetHighest(offset int, size int) (Entries, error)
|
||||
GetRandom(offset int, size int) (Entries, error)
|
||||
GetStarred() (Entries, error)
|
||||
GetByName(offset int, size int) (Entries, error)
|
||||
GetByArtist(offset int, size int) (Entries, error)
|
||||
GetStarred(offset int, size int) (Entries, error)
|
||||
GetNowPlaying() (Entries, error)
|
||||
}
|
||||
|
||||
@ -56,6 +58,16 @@ func (g listGenerator) GetHighest(offset int, size int) (Entries, error) {
|
||||
return g.query(qo, offset, size)
|
||||
}
|
||||
|
||||
func (g listGenerator) GetByName(offset int, size int) (Entries, error) {
|
||||
qo := domain.QueryOptions{SortBy: "Name", Alpha: true}
|
||||
return g.query(qo, offset, size)
|
||||
}
|
||||
|
||||
func (g listGenerator) GetByArtist(offset int, size int) (Entries, error) {
|
||||
qo := domain.QueryOptions{SortBy: "Artist", Alpha: true}
|
||||
return g.query(qo, offset, size)
|
||||
}
|
||||
|
||||
func (g listGenerator) GetRandom(offset int, size int) (Entries, error) {
|
||||
ids, err := g.albumRepo.GetAllIds()
|
||||
if err != nil {
|
||||
@ -76,8 +88,9 @@ func (g listGenerator) GetRandom(offset int, size int) (Entries, error) {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (g listGenerator) GetStarred() (Entries, error) {
|
||||
albums, err := g.albumRepo.GetStarred(domain.QueryOptions{})
|
||||
func (g listGenerator) GetStarred(offset int, size int) (Entries, error) {
|
||||
qo := domain.QueryOptions{Offset: offset, Size: size}
|
||||
albums, err := g.albumRepo.GetStarred(qo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user