implemented getStarred (just for albums, for now)
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/deluan/gosonic/utils"
|
||||
)
|
||||
|
||||
type GetAlbumListController struct {
|
||||
type AlbumListController struct {
|
||||
BaseAPIController
|
||||
listGen engine.ListGenerator
|
||||
types map[string]strategy
|
||||
@@ -18,7 +18,7 @@ type GetAlbumListController struct {
|
||||
|
||||
type strategy func(offset int, size int) (*domain.Albums, error)
|
||||
|
||||
func (c *GetAlbumListController) Prepare() {
|
||||
func (c *AlbumListController) Prepare() {
|
||||
utils.ResolveDependencies(&c.listGen)
|
||||
|
||||
c.types = map[string]strategy{
|
||||
@@ -30,12 +30,12 @@ func (c *GetAlbumListController) Prepare() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *GetAlbumListController) Get() {
|
||||
func (c *AlbumListController) GetAlbumList() {
|
||||
typ := c.RequiredParamString("type", "Required string parameter 'type' is not present")
|
||||
method, found := c.types[typ]
|
||||
|
||||
if !found {
|
||||
beego.Error("getAlbumList type", typ, "not implemented!")
|
||||
beego.Error("albumList type", typ, "not implemented!")
|
||||
c.SendError(responses.ERROR_GENERIC, "Not implemented!")
|
||||
}
|
||||
|
||||
@@ -70,3 +70,21 @@ func (c *GetAlbumListController) Get() {
|
||||
response.AlbumList = &responses.AlbumList{Album: albumList}
|
||||
c.SendResponse(response)
|
||||
}
|
||||
|
||||
func (c *AlbumListController) GetStarred() {
|
||||
albums, err := c.listGen.GetStarred()
|
||||
if err != nil {
|
||||
beego.Error("Error retrieving starred albums:", err)
|
||||
c.SendError(responses.ERROR_GENERIC, "Internal Error")
|
||||
}
|
||||
|
||||
response := c.NewEmpty()
|
||||
response.Starred = &responses.Starred{}
|
||||
response.Starred.Album = make([]responses.Child, len(*albums))
|
||||
|
||||
for i, entry := range *albums {
|
||||
response.Starred.Album[i] = c.ToChild(entry)
|
||||
}
|
||||
|
||||
c.SendResponse(response)
|
||||
}
|
||||
@@ -19,6 +19,7 @@ type Subsonic struct {
|
||||
Playlists *Playlists `xml:"playlists,omitempty" json:"playlists,omitempty"`
|
||||
Playlist *PlaylistWithSongs `xml:"playlist,omitempty" json:"playlist,omitempty"`
|
||||
SearchResult2 *SearchResult2 `xml:"searchResult2,omitempty" json:"searchResult2,omitempty"`
|
||||
Starred *Starred `xml:"starred,omitempty" json:"starred,omitempty"`
|
||||
}
|
||||
|
||||
type JsonWrapper struct {
|
||||
@@ -131,6 +132,12 @@ type SearchResult2 struct {
|
||||
Song []Child `xml:"song" json:"song,omitempty"`
|
||||
}
|
||||
|
||||
type Starred struct {
|
||||
Artist []Artist `xml:"artist" json:"artist,omitempty"`
|
||||
Album []Child `xml:"album" json:"album,omitempty"`
|
||||
Song []Child `xml:"song" json:"song,omitempty"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Username string `xml:"username,attr" json:"username"`
|
||||
Email string `xml:"email,attr,omitempty" json:"email,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user