diff --git a/cmd/server/main.go b/cmd/server/main.go index c495ee7..d5c10c7 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -81,6 +81,8 @@ func setSubsonicRoutes(cont handler.Controller, mux *http.ServeMux) { mux.HandleFunc("/rest/getIndexes.view", withWare(cont.GetIndexes)) mux.HandleFunc("/rest/getMusicDirectory", withWare(cont.GetMusicDirectory)) mux.HandleFunc("/rest/getMusicDirectory.view", withWare(cont.GetMusicDirectory)) + mux.HandleFunc("/rest/getAlbumList", withWare(cont.GetAlbumList)) + mux.HandleFunc("/rest/getAlbumList.view", withWare(cont.GetAlbumList)) } func setAdminRoutes(cont handler.Controller, mux *http.ServeMux) { diff --git a/handler/handler_sub_by_folder.go b/handler/handler_sub_by_folder.go index 2f4d288..1f5cb59 100644 --- a/handler/handler_sub_by_folder.go +++ b/handler/handler_sub_by_folder.go @@ -88,3 +88,7 @@ func (c *Controller) GetMusicDirectory(w http.ResponseWriter, r *http.Request) { } respond(w, r, sub) } + +// changes to this function should be reflected in in _by_tags.go's +// getAlbumListTwo() function +func (c *Controller) GetAlbumList(w http.ResponseWriter, r *http.Request) {} diff --git a/handler/handler_sub_by_tags.go b/handler/handler_sub_by_tags.go index 36607cb..6943208 100644 --- a/handler/handler_sub_by_tags.go +++ b/handler/handler_sub_by_tags.go @@ -104,6 +104,8 @@ func (c *Controller) GetAlbum(w http.ResponseWriter, r *http.Request) { respond(w, r, sub) } +// changes to this function should be reflected in in _by_folder.go's +// getAlbumList() function func (c *Controller) GetAlbumListTwo(w http.ResponseWriter, r *http.Request) { listType := getStrParam(r, "type") if listType == "" { @@ -119,7 +121,11 @@ func (c *Controller) GetAlbumListTwo(w http.ResponseWriter, r *http.Request) { case "alphabeticalByName": query = query.Order("title") case "byYear": - query = query.Order("year") + startYear := getIntParamOr(r, "fromYear", 1800) + endYear := getIntParamOr(r, "toYear", 2200) + query = query. + Where("year BETWEEN ? AND ?", startYear, endYear). + Order("year") case "frequent": user := r.Context().Value(contextUserKey).(*db.User) query = query. @@ -140,9 +146,11 @@ func (c *Controller) GetAlbumListTwo(w http.ResponseWriter, r *http.Request) { )) return } + offset := getIntParamOr(r, "offset", 0) size := getIntParamOr(r, "size", 10) var albums []*db.Album query. + Offset(offset). Limit(size). Preload("AlbumArtist"). Find(&albums)