diff --git a/server/subsonic/album_lists.go b/server/subsonic/album_lists.go index c453c4af4..60ce21738 100644 --- a/server/subsonic/album_lists.go +++ b/server/subsonic/album_lists.go @@ -21,7 +21,7 @@ func NewAlbumListController(listGen engine.ListGenerator) *AlbumListController { return c } -func (c *AlbumListController) getNewAlbumList(r *http.Request) (engine.Entries, error) { +func (c *AlbumListController) getAlbumList(r *http.Request) (engine.Entries, error) { typ, err := requiredParamString(r, "type", "Required string parameter 'type' is not present") if err != nil { return nil, err @@ -67,7 +67,7 @@ func (c *AlbumListController) getNewAlbumList(r *http.Request) (engine.Entries, } func (c *AlbumListController) GetAlbumList(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) { - albums, err := c.getNewAlbumList(r) + albums, err := c.getAlbumList(r) if err != nil { return nil, newError(responses.ErrorGeneric, err.Error()) } @@ -78,7 +78,7 @@ func (c *AlbumListController) GetAlbumList(w http.ResponseWriter, r *http.Reques } func (c *AlbumListController) GetAlbumList2(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) { - albums, err := c.getNewAlbumList(r) + albums, err := c.getAlbumList(r) if err != nil { return nil, newError(responses.ErrorGeneric, err.Error()) } diff --git a/server/subsonic/engine/list_generator.go b/server/subsonic/engine/list_generator.go index 646fb8fe8..60202959e 100644 --- a/server/subsonic/engine/list_generator.go +++ b/server/subsonic/engine/list_generator.go @@ -61,8 +61,13 @@ func ByGenre(genre string) ListFilter { } func ByYear(fromYear, toYear int) ListFilter { + sortOption := "max_year, name" + if fromYear > toYear { + fromYear, toYear = toYear, fromYear + sortOption = "max_year desc, name" + } return ListFilter{ - Sort: "max_year, name", + Sort: sortOption, Filters: squirrel.Or{ squirrel.And{ squirrel.GtOrEq{"min_year": fromYear},