feat(subsonic): set sortName for OS AlbumList (#3776)
* feat(subsonic): Set SortName for OS AlbumList, test to JSON/XML * albumlist2, star2 updated properly * fix(subsonic): add sort or order name based on config Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org> Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
+62
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"status": "ok",
|
||||
"version": "1.8.0",
|
||||
"type": "navidrome",
|
||||
"serverVersion": "v0.0.0",
|
||||
"openSubsonic": true,
|
||||
"albumList": {
|
||||
"album": [
|
||||
{
|
||||
"id": "1",
|
||||
"isDir": false,
|
||||
"isVideo": false,
|
||||
"bpm": 0,
|
||||
"comment": "",
|
||||
"sortName": "sort name",
|
||||
"mediaType": "album",
|
||||
"musicBrainzId": "00000000-0000-0000-0000-000000000000",
|
||||
"genres": [
|
||||
{
|
||||
"name": "Genre 1"
|
||||
},
|
||||
{
|
||||
"name": "Genre 2"
|
||||
}
|
||||
],
|
||||
"replayGain": {},
|
||||
"channelCount": 0,
|
||||
"samplingRate": 0,
|
||||
"bitDepth": 0,
|
||||
"moods": [
|
||||
"mood1",
|
||||
"mood2"
|
||||
],
|
||||
"artists": [
|
||||
{
|
||||
"id": "artist-1",
|
||||
"name": "Artist 1"
|
||||
},
|
||||
{
|
||||
"id": "artist-2",
|
||||
"name": "Artist 2"
|
||||
}
|
||||
],
|
||||
"displayArtist": "Display artist",
|
||||
"albumArtists": [
|
||||
{
|
||||
"id": "album-artist-1",
|
||||
"name": "Artist 1"
|
||||
},
|
||||
{
|
||||
"id": "album-artist-2",
|
||||
"name": "Artist 2"
|
||||
}
|
||||
],
|
||||
"displayAlbumArtist": "Display album artist",
|
||||
"contributors": [],
|
||||
"displayComposer": "",
|
||||
"explicitStatus": "explicit"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
|
||||
<albumList>
|
||||
<album id="1" isDir="false" isVideo="false" sortName="sort name" mediaType="album" musicBrainzId="00000000-0000-0000-0000-000000000000" displayArtist="Display artist" displayAlbumArtist="Display album artist" explicitStatus="explicit">
|
||||
<genres name="Genre 1"></genres>
|
||||
<genres name="Genre 2"></genres>
|
||||
<moods>mood1</moods>
|
||||
<moods>mood2</moods>
|
||||
<artists id="artist-1" name="Artist 1"></artists>
|
||||
<artists id="artist-2" name="Artist 2"></artists>
|
||||
<albumArtists id="album-artist-1" name="Artist 1"></albumArtists>
|
||||
<albumArtists id="album-artist-2" name="Artist 2"></albumArtists>
|
||||
</album>
|
||||
</albumList>
|
||||
</subsonic-response>
|
||||
@@ -21,13 +21,13 @@ type Subsonic struct {
|
||||
User *User `xml:"user,omitempty" json:"user,omitempty"`
|
||||
Users *Users `xml:"users,omitempty" json:"users,omitempty"`
|
||||
AlbumList *AlbumList `xml:"albumList,omitempty" json:"albumList,omitempty"`
|
||||
AlbumList2 *AlbumList `xml:"albumList2,omitempty" json:"albumList2,omitempty"`
|
||||
AlbumList2 *AlbumList2 `xml:"albumList2,omitempty" json:"albumList2,omitempty"`
|
||||
Playlists *Playlists `xml:"playlists,omitempty" json:"playlists,omitempty"`
|
||||
Playlist *PlaylistWithSongs `xml:"playlist,omitempty" json:"playlist,omitempty"`
|
||||
SearchResult2 *SearchResult2 `xml:"searchResult2,omitempty" json:"searchResult2,omitempty"`
|
||||
SearchResult3 *SearchResult3 `xml:"searchResult3,omitempty" json:"searchResult3,omitempty"`
|
||||
Starred *Starred `xml:"starred,omitempty" json:"starred,omitempty"`
|
||||
Starred2 *Starred `xml:"starred2,omitempty" json:"starred2,omitempty"`
|
||||
Starred2 *Starred2 `xml:"starred2,omitempty" json:"starred2,omitempty"`
|
||||
NowPlaying *NowPlaying `xml:"nowPlaying,omitempty" json:"nowPlaying,omitempty"`
|
||||
Song *Child `xml:"song,omitempty" json:"song,omitempty"`
|
||||
RandomSongs *Songs `xml:"randomSongs,omitempty" json:"randomSongs,omitempty"`
|
||||
@@ -297,6 +297,10 @@ type AlbumList struct {
|
||||
Album []Child `xml:"album" json:"album,omitempty"`
|
||||
}
|
||||
|
||||
type AlbumList2 struct {
|
||||
Album []AlbumID3 `xml:"album" json:"album,omitempty"`
|
||||
}
|
||||
|
||||
type Playlist struct {
|
||||
Id string `xml:"id,attr" json:"id"`
|
||||
Name string `xml:"name,attr" json:"name"`
|
||||
@@ -342,6 +346,12 @@ type Starred struct {
|
||||
Song []Child `xml:"song" json:"song,omitempty"`
|
||||
}
|
||||
|
||||
type Starred2 struct {
|
||||
Artist []ArtistID3 `xml:"artist" json:"artist,omitempty"`
|
||||
Album []AlbumID3 `xml:"album" json:"album,omitempty"`
|
||||
Song []Child `xml:"song" json:"song,omitempty"`
|
||||
}
|
||||
|
||||
type NowPlayingEntry struct {
|
||||
Child
|
||||
UserName string `xml:"username,attr" json:"username"`
|
||||
|
||||
@@ -403,6 +403,42 @@ var _ = Describe("Responses", func() {
|
||||
Expect(json.MarshalIndent(response, "", " ")).To(MatchSnapshot())
|
||||
})
|
||||
})
|
||||
|
||||
Context("with OS data", func() {
|
||||
BeforeEach(func() {
|
||||
child := make([]Child, 1)
|
||||
child[0] = Child{Id: "1", OpenSubsonicChild: &OpenSubsonicChild{
|
||||
MediaType: MediaTypeAlbum,
|
||||
MusicBrainzId: "00000000-0000-0000-0000-000000000000",
|
||||
Genres: Array[ItemGenre]{
|
||||
ItemGenre{Name: "Genre 1"},
|
||||
ItemGenre{Name: "Genre 2"},
|
||||
},
|
||||
Moods: []string{"mood1", "mood2"},
|
||||
DisplayArtist: "Display artist",
|
||||
Artists: Array[ArtistID3Ref]{
|
||||
ArtistID3Ref{Id: "artist-1", Name: "Artist 1"},
|
||||
ArtistID3Ref{Id: "artist-2", Name: "Artist 2"},
|
||||
},
|
||||
DisplayAlbumArtist: "Display album artist",
|
||||
AlbumArtists: Array[ArtistID3Ref]{
|
||||
ArtistID3Ref{Id: "album-artist-1", Name: "Artist 1"},
|
||||
ArtistID3Ref{Id: "album-artist-2", Name: "Artist 2"},
|
||||
},
|
||||
ExplicitStatus: "explicit",
|
||||
SortName: "sort name",
|
||||
}}
|
||||
response.AlbumList.Album = child
|
||||
|
||||
})
|
||||
|
||||
It("should match .XML", func() {
|
||||
Expect(xml.MarshalIndent(response, "", " ")).To(MatchSnapshot())
|
||||
})
|
||||
It("should match .JSON", func() {
|
||||
Expect(json.MarshalIndent(response, "", " ")).To(MatchSnapshot())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("User", func() {
|
||||
|
||||
Reference in New Issue
Block a user