getAlbum.view implemented
This commit is contained in:
+46
-7
@@ -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
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ type Subsonic struct {
|
||||
// ID3
|
||||
Artist *Indexes `xml:"artists,omitempty" json:"artists,omitempty"`
|
||||
ArtistWithAlbumsID3 *ArtistWithAlbumsID3 `xml:"artist,omitempty" json:"artist,omitempty"`
|
||||
AlbumWithSongsID3 *AlbumWithSongsID3 `xml:"album,omitempty" json:"album,omitempty"`
|
||||
}
|
||||
|
||||
type JsonWrapper struct {
|
||||
@@ -136,14 +137,37 @@ type Directory struct {
|
||||
*/
|
||||
}
|
||||
|
||||
type ArtistWithAlbumsID3 struct {
|
||||
Album []Child `xml:"album" json:"album,omitempty"`
|
||||
type ArtistID3 struct {
|
||||
Id string `xml:"id,attr" json:"id"`
|
||||
Name string `xml:"name,attr" json:"name"`
|
||||
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
|
||||
PlayCount int32 `xml:"playCount,attr,omitempty" json:"playcount,omitempty"`
|
||||
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
|
||||
CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
|
||||
AlbumCount int `xml:"albumCount,attr,omitempty" json:"albumCount,omitempty"`
|
||||
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
|
||||
}
|
||||
|
||||
type AlbumID3 struct {
|
||||
Id string `xml:"id,attr" json:"id"`
|
||||
Name string `xml:"name,attr" json:"name"`
|
||||
Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
|
||||
ArtistId string `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
|
||||
CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
|
||||
SongCount int `xml:"songCount,attr,omitempty" json:"songCount,omitempty"`
|
||||
Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
|
||||
PlayCount int32 `xml:"playCount,attr,omitempty" json:"playcount,omitempty"`
|
||||
Created *time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
|
||||
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
|
||||
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
|
||||
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
|
||||
}
|
||||
|
||||
type ArtistWithAlbumsID3 struct {
|
||||
ArtistID3
|
||||
Album []Child `xml:"album" json:"album,omitempty"`
|
||||
}
|
||||
|
||||
type AlbumWithSongsID3 struct {
|
||||
AlbumID3
|
||||
Song []Child `xml:"song" json:"song,omitempty"`
|
||||
}
|
||||
|
||||
type AlbumList struct {
|
||||
|
||||
Reference in New Issue
Block a user