From 5b76ab4e4bc5b94b3d96a0f4addbf5e78f7d417a Mon Sep 17 00:00:00 2001 From: sentriz Date: Sun, 12 Apr 2020 18:26:39 +0100 Subject: [PATCH] add year and artist to getalbum response closes #55 --- server/ctrlsubsonic/handlers_by_tags.go | 1 + server/ctrlsubsonic/spec/construct_by_tags.go | 4 ++++ server/ctrlsubsonic/spec/spec.go | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/ctrlsubsonic/handlers_by_tags.go b/server/ctrlsubsonic/handlers_by_tags.go index 73ef57d..7c37503 100644 --- a/server/ctrlsubsonic/handlers_by_tags.go +++ b/server/ctrlsubsonic/handlers_by_tags.go @@ -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") }). diff --git a/server/ctrlsubsonic/spec/construct_by_tags.go b/server/ctrlsubsonic/spec/construct_by_tags.go index eca7766..1886077 100644 --- a/server/ctrlsubsonic/spec/construct_by_tags.go +++ b/server/ctrlsubsonic/spec/construct_by_tags.go @@ -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 } diff --git a/server/ctrlsubsonic/spec/spec.go b/server/ctrlsubsonic/spec/spec.go index 8a8dcbe..da20b09 100644 --- a/server/ctrlsubsonic/spec/spec.go +++ b/server/ctrlsubsonic/spec/spec.go @@ -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"` }