diff --git a/server/ctrlsubsonic/spec/construct_by_tags.go b/server/ctrlsubsonic/spec/construct_by_tags.go index 565b2a2..a959edb 100644 --- a/server/ctrlsubsonic/spec/construct_by_tags.go +++ b/server/ctrlsubsonic/spec/construct_by_tags.go @@ -36,8 +36,10 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album { ret.ArtistID = artists[0].SID() } for _, a := range artists { - ret.Artists = append(ret.Artists, a.Name) - ret.ArtistIDs = append(ret.ArtistIDs, a.SID()) + ret.Artists = append(ret.Artists, &ArtistRef{ + ID: a.SID(), + Name: a.Name, + }) } return ret } diff --git a/server/ctrlsubsonic/spec/spec.go b/server/ctrlsubsonic/spec/spec.go index 60c2dd8..00fcc01 100644 --- a/server/ctrlsubsonic/spec/spec.go +++ b/server/ctrlsubsonic/spec/spec.go @@ -111,15 +111,19 @@ type Albums struct { List []*Album `xml:"album" json:"album"` } +type ArtistRef struct { + ID *specid.ID `xml:"id,attr" json:"id"` + Name string `xml:"name,attr" json:"name"` +} + type Album struct { // common - ID *specid.ID `xml:"id,attr,omitempty" json:"id"` - CoverID *specid.ID `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"` - ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"` - Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"` - ArtistIDs []*specid.ID `xml:"artistIds,attr,omitempty" json:"artistIds,omitempty"` - Artists []string `xml:"artists,attr,omitempty" json:"artists,omitempty"` - Created time.Time `xml:"created,attr,omitempty" json:"created,omitempty"` + ID *specid.ID `xml:"id,attr,omitempty" json:"id"` + CoverID *specid.ID `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"` + ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"` + Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"` + Artists []*ArtistRef `xml:"artists,omitempty" json:"artists,omitempty"` + Created time.Time `xml:"created,attr,omitempty" json:"created,omitempty"` // browsing by folder (eg. getAlbumList) Title string `xml:"title,attr,omitempty" json:"title"` Album string `xml:"album,attr,omitempty" json:"album"` diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_artist b/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_artist index 11c1791..f5573f7 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_artist +++ b/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_artist @@ -11,8 +11,7 @@ "coverArt": "al-3", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -26,8 +25,7 @@ "coverArt": "al-4", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -41,8 +39,7 @@ "coverArt": "al-5", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -56,8 +53,7 @@ "coverArt": "al-7", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -71,8 +67,7 @@ "coverArt": "al-8", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -86,8 +81,7 @@ "coverArt": "al-9", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -101,8 +95,7 @@ "coverArt": "al-11", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -116,8 +109,7 @@ "coverArt": "al-12", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -131,8 +123,7 @@ "coverArt": "al-13", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_name b/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_name index d8bffaa..44357c2 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_name +++ b/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_name @@ -11,8 +11,7 @@ "coverArt": "al-3", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -26,8 +25,7 @@ "coverArt": "al-7", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -41,8 +39,7 @@ "coverArt": "al-11", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -56,8 +53,7 @@ "coverArt": "al-4", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -71,8 +67,7 @@ "coverArt": "al-8", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -86,8 +81,7 @@ "coverArt": "al-12", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -101,8 +95,7 @@ "coverArt": "al-5", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -116,8 +109,7 @@ "coverArt": "al-9", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -131,8 +123,7 @@ "coverArt": "al-13", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_two_newest b/server/ctrlsubsonic/testdata/test_get_album_list_two_newest index 11c1791..f5573f7 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_two_newest +++ b/server/ctrlsubsonic/testdata/test_get_album_list_two_newest @@ -11,8 +11,7 @@ "coverArt": "al-3", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -26,8 +25,7 @@ "coverArt": "al-4", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -41,8 +39,7 @@ "coverArt": "al-5", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -56,8 +53,7 @@ "coverArt": "al-7", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -71,8 +67,7 @@ "coverArt": "al-8", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -86,8 +81,7 @@ "coverArt": "al-9", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -101,8 +95,7 @@ "coverArt": "al-11", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -116,8 +109,7 @@ "coverArt": "al-12", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -131,8 +123,7 @@ "coverArt": "al-13", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_two_random b/server/ctrlsubsonic/testdata/test_get_album_list_two_random index d36a5bd..e6e1378 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_two_random +++ b/server/ctrlsubsonic/testdata/test_get_album_list_two_random @@ -7,12 +7,25 @@ "albumList2": { "album": [ { - "id": "al-11", - "coverArt": "al-11", - "artistId": "ar-3", - "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "id": "al-3", + "coverArt": "al-3", + "artistId": "ar-1", + "artist": "artist-0", + "artists": [{ "id": "ar-1", "name": "artist-0" }], + "created": "2019-11-30T00:00:00Z", + "title": "", + "album": "", + "name": "album-0", + "songCount": 3, + "duration": 300, + "year": 2021 + }, + { + "id": "al-7", + "coverArt": "al-7", + "artistId": "ar-2", + "artist": "artist-1", + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -26,8 +39,7 @@ "coverArt": "al-8", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -37,12 +49,11 @@ "year": 2021 }, { - "id": "al-3", - "coverArt": "al-3", - "artistId": "ar-1", - "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "id": "al-11", + "coverArt": "al-11", + "artistId": "ar-3", + "artist": "artist-2", + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -51,28 +62,12 @@ "duration": 300, "year": 2021 }, - { - "id": "al-13", - "coverArt": "al-13", - "artistId": "ar-3", - "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], - "created": "2019-11-30T00:00:00Z", - "title": "", - "album": "", - "name": "album-2", - "songCount": 3, - "duration": 300, - "year": 2021 - }, { "id": "al-12", "coverArt": "al-12", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -81,13 +76,26 @@ "duration": 300, "year": 2021 }, + { + "id": "al-13", + "coverArt": "al-13", + "artistId": "ar-3", + "artist": "artist-2", + "artists": [{ "id": "ar-3", "name": "artist-2" }], + "created": "2019-11-30T00:00:00Z", + "title": "", + "album": "", + "name": "album-2", + "songCount": 3, + "duration": 300, + "year": 2021 + }, { "id": "al-9", "coverArt": "al-9", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -101,8 +109,7 @@ "coverArt": "al-5", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -111,28 +118,12 @@ "duration": 300, "year": 2021 }, - { - "id": "al-7", - "coverArt": "al-7", - "artistId": "ar-2", - "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], - "created": "2019-11-30T00:00:00Z", - "title": "", - "album": "", - "name": "album-0", - "songCount": 3, - "duration": 300, - "year": 2021 - }, { "id": "al-4", "coverArt": "al-4", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", diff --git a/server/ctrlsubsonic/testdata/test_get_album_with_cover b/server/ctrlsubsonic/testdata/test_get_album_with_cover index 6a27840..c9c8c4a 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_with_cover +++ b/server/ctrlsubsonic/testdata/test_get_album_with_cover @@ -9,8 +9,7 @@ "coverArt": "al-3", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", diff --git a/server/ctrlsubsonic/testdata/test_get_artist_id_one b/server/ctrlsubsonic/testdata/test_get_artist_id_one index 7135120..5b28be4 100644 --- a/server/ctrlsubsonic/testdata/test_get_artist_id_one +++ b/server/ctrlsubsonic/testdata/test_get_artist_id_one @@ -15,8 +15,7 @@ "coverArt": "al-3", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -30,8 +29,7 @@ "coverArt": "al-4", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -45,8 +43,7 @@ "coverArt": "al-5", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", diff --git a/server/ctrlsubsonic/testdata/test_get_artist_id_three b/server/ctrlsubsonic/testdata/test_get_artist_id_three index 860fa36..e759357 100644 --- a/server/ctrlsubsonic/testdata/test_get_artist_id_three +++ b/server/ctrlsubsonic/testdata/test_get_artist_id_three @@ -15,8 +15,7 @@ "coverArt": "al-11", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -30,8 +29,7 @@ "coverArt": "al-12", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -45,8 +43,7 @@ "coverArt": "al-13", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", diff --git a/server/ctrlsubsonic/testdata/test_get_artist_id_two b/server/ctrlsubsonic/testdata/test_get_artist_id_two index e3de495..98f59b4 100644 --- a/server/ctrlsubsonic/testdata/test_get_artist_id_two +++ b/server/ctrlsubsonic/testdata/test_get_artist_id_two @@ -15,8 +15,7 @@ "coverArt": "al-7", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -30,8 +29,7 @@ "coverArt": "al-8", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -45,8 +43,7 @@ "coverArt": "al-9", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", diff --git a/server/ctrlsubsonic/testdata/test_search_three_q_alb b/server/ctrlsubsonic/testdata/test_search_three_q_alb index b5e038c..122add3 100644 --- a/server/ctrlsubsonic/testdata/test_search_three_q_alb +++ b/server/ctrlsubsonic/testdata/test_search_three_q_alb @@ -11,8 +11,7 @@ "coverArt": "al-3", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -27,8 +26,7 @@ "coverArt": "al-4", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -43,8 +41,7 @@ "coverArt": "al-5", "artistId": "ar-1", "artist": "artist-0", - "artistIds": ["ar-1"], - "artists": ["artist-0"], + "artists": [{ "id": "ar-1", "name": "artist-0" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -59,8 +56,7 @@ "coverArt": "al-7", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -75,8 +71,7 @@ "coverArt": "al-8", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -91,8 +86,7 @@ "coverArt": "al-9", "artistId": "ar-2", "artist": "artist-1", - "artistIds": ["ar-2"], - "artists": ["artist-1"], + "artists": [{ "id": "ar-2", "name": "artist-1" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -107,8 +101,7 @@ "coverArt": "al-11", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -123,8 +116,7 @@ "coverArt": "al-12", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "", @@ -139,8 +131,7 @@ "coverArt": "al-13", "artistId": "ar-3", "artist": "artist-2", - "artistIds": ["ar-3"], - "artists": ["artist-2"], + "artists": [{ "id": "ar-3", "name": "artist-2" }], "created": "2019-11-30T00:00:00Z", "title": "", "album": "",