getAlbum.view implemented

This commit is contained in:
Deluan
2016-03-28 09:16:03 -04:00
parent 82576223dc
commit 615dc862af
4 changed files with 102 additions and 27 deletions
+46 -7
View File
@@ -111,6 +111,24 @@ func (c *BrowsingController) GetArtist() {
c.SendResponse(response)
}
func (c *BrowsingController) GetAlbum() {
id := c.RequiredParamString("id", "id parameter required")
dir, err := c.browser.Album(id)
switch {
case err == domain.ErrNotFound:
beego.Error("Requested AlbumId", id, "not found:", err)
c.SendError(responses.ErrorDataNotFound, "Album not found")
case err != nil:
beego.Error(err)
c.SendError(responses.ErrorGeneric, "Internal Error")
}
response := c.NewEmpty()
response.AlbumWithSongsID3 = c.buildAlbum(dir)
c.SendResponse(response)
}
func (c *BrowsingController) GetSong() {
id := c.RequiredParamString("id", "id parameter required")
@@ -148,13 +166,11 @@ func (c *BrowsingController) buildDirectory(d *engine.DirectoryInfo) *responses.
}
func (c *BrowsingController) buildArtist(d *engine.DirectoryInfo) *responses.ArtistWithAlbumsID3 {
dir := &responses.ArtistWithAlbumsID3{
Id: d.Id,
Name: d.Name,
PlayCount: d.PlayCount,
AlbumCount: d.AlbumCount,
UserRating: d.UserRating,
}
dir := &responses.ArtistWithAlbumsID3{}
dir.Id = d.Id
dir.Name = d.Name
dir.AlbumCount = d.AlbumCount
dir.CoverArt = d.CoverArt
if !d.Starred.IsZero() {
dir.Starred = &d.Starred
}
@@ -162,3 +178,26 @@ func (c *BrowsingController) buildArtist(d *engine.DirectoryInfo) *responses.Art
dir.Album = c.ToAlbums(d.Entries)
return dir
}
func (c *BrowsingController) buildAlbum(d *engine.DirectoryInfo) *responses.AlbumWithSongsID3 {
dir := &responses.AlbumWithSongsID3{}
dir.Id = d.Id
dir.Name = d.Name
dir.Artist = d.Artist
dir.ArtistId = d.ArtistId
dir.CoverArt = d.CoverArt
dir.SongCount = d.SongCount
dir.Duration = d.Duration
dir.PlayCount = d.PlayCount
dir.Year = d.Year
dir.Genre = d.Genre
if !d.Created.IsZero() {
dir.Created = &d.Created
}
if !d.Starred.IsZero() {
dir.Starred = &d.Starred
}
dir.Song = c.ToChildren(d.Entries)
return dir
}