add year and artist to getalbum response

closes #55
This commit is contained in:
sentriz
2020-04-12 18:26:39 +01:00
parent 0a9cfcb0b7
commit 5b76ab4e4b
3 changed files with 9 additions and 2 deletions

View File

@@ -77,6 +77,7 @@ func (c *Controller) ServeGetAlbum(r *http.Request) *spec.Response {
album := &db.Album{}
err = c.DB.
Preload("TagArtist").
Preload("TagGenre").
Preload("Tracks", func(db *gorm.DB) *gorm.DB {
return db.Order("tracks.tag_disc_number, tracks.tag_track_number")
}).

View File

@@ -11,8 +11,12 @@ func NewAlbumByTags(a *db.Album, artist *db.Artist) *Album {
Created: a.ModifiedAt,
ID: a.ID,
Name: a.TagTitle,
Year: a.TagYear,
TrackCount: a.ChildCount,
}
if a.TagGenre != nil {
ret.Genre = a.TagGenre.Name
}
if a.Cover != "" {
ret.CoverID = a.ID
}

View File

@@ -92,16 +92,18 @@ type Album struct {
CoverID int `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty,string"`
ArtistID int `xml:"artistId,attr,omitempty" json:"artistId,omitempty,string"`
Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
// browsing by folder (getAlbumList)
// browsing by folder (eg. getAlbumList)
Title string `xml:"title,attr,omitempty" json:"title,omitempty"`
Album string `xml:"album,attr,omitempty" json:"album,omitempty"`
ParentID int `xml:"parent,attr,omitempty" json:"parent,omitempty,string"`
IsDir bool `xml:"isDir,attr,omitempty" json:"isDir,omitempty"`
// browsing by tags (getAlbumList2)
// browsing by tags (eg. getAlbumList2)
Name string `xml:"name,attr,omitempty" json:"name,omitempty"`
TrackCount int `xml:"songCount,attr" json:"songCount"`
Duration int `xml:"duration,attr" json:"duration"`
Created time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
}