Skip to content

Commit

Permalink
return artist reference objects in subsonic album type
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Sep 10, 2023
1 parent ddd1605 commit d6b35f8
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 146 deletions.
6 changes: 4 additions & 2 deletions server/ctrlsubsonic/spec/construct_by_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 11 additions & 7 deletions server/ctrlsubsonic/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
27 changes: 9 additions & 18 deletions server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_artist
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand Down
27 changes: 9 additions & 18 deletions server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_name
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand Down
27 changes: 9 additions & 18 deletions server/ctrlsubsonic/testdata/test_get_album_list_two_newest
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand Down
Loading

0 comments on commit d6b35f8

Please sign in to comment.