return artist reference objects in subsonic album type

https://github.com/opensubsonic/open-subsonic-api/discussions/8
This commit is contained in:
sentriz
2023-09-10 17:54:56 +01:00
parent ddd160545c
commit d6b35f8c79
11 changed files with 104 additions and 153 deletions

View File

@@ -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
}

View File

@@ -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"`

View File

@@ -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": "",

View File

@@ -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": "",

View File

@@ -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": "",

View File

@@ -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": "",

View File

@@ -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": "",

View File

@@ -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": "",

View File

@@ -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": "",

View File

@@ -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": "",

View File

@@ -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": "",