Add more OpenSubsonic fields

- isCompilation
- sortName
This commit is contained in:
Deluan 2023-11-28 21:26:00 -05:00
parent f580c5b8bc
commit cdccdc56c9
28 changed files with 75 additions and 44 deletions

View File

@ -432,6 +432,8 @@ func (api *Router) buildAlbum(ctx context.Context, album *model.Album, mfs model
dir.Starred = &album.StarredAt
}
dir.MusicBrainzId = album.MbzAlbumID
dir.IsCompilation = album.Compilation
dir.SortName = album.SortAlbumName
dir.Song = childrenFromMediaFiles(ctx, mfs)
return dir
}

View File

@ -111,6 +111,7 @@ func toArtistID3(r *http.Request, a model.Artist) responses.ArtistID3 {
ArtistImageUrl: public.ImageURL(r, a.CoverArtID(), 600),
UserRating: int32(a.Rating),
MusicBrainzId: a.MbzArtistID,
SortName: a.SortArtistName,
}
if a.Starred {
artist.Starred = &a.StarredAt
@ -187,6 +188,7 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child
}
child.BookmarkPosition = mf.BookmarkPosition
child.Comment = mf.Comment
child.SortName = mf.SortTitle
child.Bpm = int32(mf.Bpm)
child.MediaType = responses.MediaTypeSong
child.MusicBrainzId = mf.MbzRecordingID
@ -238,6 +240,7 @@ func childFromAlbum(_ context.Context, al model.Album) responses.Child {
child.Played = &al.PlayDate
}
child.UserRating = int32(al.Rating)
child.SortName = al.SortAlbumName
child.MediaType = responses.MediaTypeAlbum
child.MusicBrainzId = al.MbzAlbumID
return child

View File

@ -11,10 +11,11 @@
"isDir": false,
"title": "title",
"isVideo": false,
"mediaType": "",
"musicBrainzId": "",
"bpm": 0,
"comment": "",
"sortName": "",
"mediaType": "",
"musicBrainzId": "",
"genres": []
}
]

View File

@ -1,5 +1,5 @@
<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" title="title" isVideo="false" mediaType="" musicBrainzId="" bpm="0" comment=""></album>
<album id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></album>
</albumList>
</subsonic-response>

View File

@ -19,6 +19,8 @@
}
],
"musicBrainzId": "1234",
"isCompilation": true,
"sortName": "sorted album",
"song": [
{
"id": "1",
@ -39,10 +41,11 @@
"duration": 146,
"bitRate": 320,
"isVideo": false,
"mediaType": "song",
"musicBrainzId": "4321",
"bpm": 127,
"comment": "a comment",
"sortName": "sorted song",
"mediaType": "song",
"musicBrainzId": "4321",
"genres": [
{
"name": "rock"

View File

@ -1,8 +1,8 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<album id="1" name="album" artist="artist" genre="rock" userRating="0" musicBrainzId="1234">
<album id="1" name="album" artist="artist" genre="rock" userRating="0" musicBrainzId="1234" isCompilation="true" sortName="sorted album">
<genres name="rock"></genres>
<genres name="progressive"></genres>
<song id="1" isDir="true" title="title" album="album" artist="artist" track="1" year="1985" genre="Rock" coverArt="1" size="8421341" contentType="audio/flac" suffix="flac" starred="2016-03-02T20:30:00Z" transcodedContentType="audio/mpeg" transcodedSuffix="mp3" duration="146" bitRate="320" isVideo="false" mediaType="song" musicBrainzId="4321" bpm="127" comment="a comment">
<song id="1" isDir="true" title="title" album="album" artist="artist" track="1" year="1985" genre="Rock" coverArt="1" size="8421341" contentType="audio/flac" suffix="flac" starred="2016-03-02T20:30:00Z" transcodedContentType="audio/mpeg" transcodedSuffix="mp3" duration="146" bitRate="320" isVideo="false" bpm="127" comment="a comment" sortName="sorted song" mediaType="song" musicBrainzId="4321">
<genres name="rock"></genres>
<genres name="progressive"></genres>
</song>

View File

@ -9,6 +9,8 @@
"name": "",
"userRating": 0,
"genres": [],
"musicBrainzId": ""
"musicBrainzId": "",
"isCompilation": false,
"sortName": ""
}
}

View File

@ -1,3 +1,3 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<album id="" name="" userRating="0" musicBrainzId=""></album>
<album id="" name="" userRating="0" musicBrainzId="" isCompilation="false" sortName=""></album>
</subsonic-response>

View File

@ -12,10 +12,11 @@
"isDir": false,
"title": "title",
"isVideo": false,
"mediaType": "",
"musicBrainzId": "",
"bpm": 0,
"comment": "",
"sortName": "",
"mediaType": "",
"musicBrainzId": "",
"genres": []
},
"position": 123,

View File

@ -1,7 +1,7 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<bookmarks>
<bookmark position="123" username="user2" comment="a comment" created="0001-01-01T00:00:00Z" changed="0001-01-01T00:00:00Z">
<entry id="1" isDir="false" title="title" isVideo="false" mediaType="" musicBrainzId="" bpm="0" comment=""></entry>
<entry id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></entry>
</bookmark>
</bookmarks>
</subsonic-response>

View File

@ -25,10 +25,11 @@
"duration": 146,
"bitRate": 320,
"isVideo": false,
"mediaType": "song",
"musicBrainzId": "4321",
"bpm": 127,
"comment": "a comment",
"sortName": "",
"mediaType": "song",
"musicBrainzId": "4321",
"genres": [
{
"name": "rock"

View File

@ -1,6 +1,6 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<directory id="1" name="N">
<child id="1" isDir="true" title="title" album="album" artist="artist" track="1" year="1985" genre="Rock" coverArt="1" size="8421341" contentType="audio/flac" suffix="flac" starred="2016-03-02T20:30:00Z" transcodedContentType="audio/mpeg" transcodedSuffix="mp3" duration="146" bitRate="320" isVideo="false" mediaType="song" musicBrainzId="4321" bpm="127" comment="a comment">
<child id="1" isDir="true" title="title" album="album" artist="artist" track="1" year="1985" genre="Rock" coverArt="1" size="8421341" contentType="audio/flac" suffix="flac" starred="2016-03-02T20:30:00Z" transcodedContentType="audio/mpeg" transcodedSuffix="mp3" duration="146" bitRate="320" isVideo="false" bpm="127" comment="a comment" sortName="" mediaType="song" musicBrainzId="4321">
<genres name="rock"></genres>
<genres name="progressive"></genres>
</child>

View File

@ -10,10 +10,11 @@
"id": "1",
"isDir": false,
"isVideo": false,
"mediaType": "",
"musicBrainzId": "",
"bpm": 0,
"comment": "",
"sortName": "",
"mediaType": "",
"musicBrainzId": "",
"genres": []
}
],

View File

@ -1,5 +1,5 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<directory id="" name="">
<child id="1" isDir="false" isVideo="false" mediaType="" musicBrainzId="" bpm="0" comment=""></child>
<child id="1" isDir="false" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></child>
</directory>
</subsonic-response>

View File

@ -11,10 +11,11 @@
"isDir": false,
"title": "title",
"isVideo": false,
"mediaType": "",
"musicBrainzId": "",
"bpm": 0,
"comment": "",
"sortName": "",
"mediaType": "",
"musicBrainzId": "",
"genres": []
}
],

View File

@ -1,5 +1,5 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<directory id="1" name="N">
<child id="1" isDir="false" title="title" isVideo="false" mediaType="" musicBrainzId="" bpm="0" comment=""></child>
<child id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></child>
</directory>
</subsonic-response>

View File

@ -11,10 +11,11 @@
"isDir": false,
"title": "title",
"isVideo": false,
"mediaType": "",
"musicBrainzId": "",
"bpm": 0,
"comment": "",
"sortName": "",
"mediaType": "",
"musicBrainzId": "",
"genres": []
}
],

View File

@ -1,5 +1,5 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<playQueue current="111" position="243" username="user1" changed="0001-01-01T00:00:00Z" changedBy="a_client">
<entry id="1" isDir="false" title="title" isVideo="false" mediaType="" musicBrainzId="" bpm="0" comment=""></entry>
<entry id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></entry>
</playQueue>
</subsonic-response>

View File

@ -16,10 +16,11 @@
"artist": "artist",
"duration": 120,
"isVideo": false,
"mediaType": "",
"musicBrainzId": "",
"bpm": 0,
"comment": "",
"sortName": "",
"mediaType": "",
"musicBrainzId": "",
"genres": []
},
{
@ -30,10 +31,11 @@
"artist": "artist",
"duration": 300,
"isVideo": false,
"mediaType": "",
"musicBrainzId": "",
"bpm": 0,
"comment": "",
"sortName": "",
"mediaType": "",
"musicBrainzId": "",
"genres": []
}
],

View File

@ -1,8 +1,8 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<shares>
<share id="ABC123" url="http://localhost/p/ABC123" description="Check it out!" username="deluan" created="0001-01-01T00:00:00Z" expires="0001-01-01T00:00:00Z" lastVisited="0001-01-01T00:00:00Z" visitCount="2">
<entry id="1" isDir="false" title="title" album="album" artist="artist" duration="120" isVideo="false" mediaType="" musicBrainzId="" bpm="0" comment=""></entry>
<entry id="2" isDir="false" title="title 2" album="album" artist="artist" duration="300" isVideo="false" mediaType="" musicBrainzId="" bpm="0" comment=""></entry>
<entry id="1" isDir="false" title="title" album="album" artist="artist" duration="120" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></entry>
<entry id="2" isDir="false" title="title 2" album="album" artist="artist" duration="300" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></entry>
</share>
</shares>
</subsonic-response>

View File

@ -11,10 +11,11 @@
"isDir": false,
"title": "title",
"isVideo": false,
"mediaType": "",
"musicBrainzId": "",
"bpm": 0,
"comment": "",
"sortName": "",
"mediaType": "",
"musicBrainzId": "",
"genres": []
}
]

View File

@ -1,5 +1,5 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<similarSongs>
<song id="1" isDir="false" title="title" isVideo="false" mediaType="" musicBrainzId="" bpm="0" comment=""></song>
<song id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></song>
</similarSongs>
</subsonic-response>

View File

@ -11,10 +11,11 @@
"isDir": false,
"title": "title",
"isVideo": false,
"mediaType": "",
"musicBrainzId": "",
"bpm": 0,
"comment": "",
"sortName": "",
"mediaType": "",
"musicBrainzId": "",
"genres": []
}
]

View File

@ -1,5 +1,5 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<similarSongs2>
<song id="1" isDir="false" title="title" isVideo="false" mediaType="" musicBrainzId="" bpm="0" comment=""></song>
<song id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></song>
</similarSongs2>
</subsonic-response>

View File

@ -11,10 +11,11 @@
"isDir": false,
"title": "title",
"isVideo": false,
"mediaType": "",
"musicBrainzId": "",
"bpm": 0,
"comment": "",
"sortName": "",
"mediaType": "",
"musicBrainzId": "",
"genres": []
}
]

View File

@ -1,5 +1,5 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<topSongs>
<song id="1" isDir="false" title="title" isVideo="false" mediaType="" musicBrainzId="" bpm="0" comment=""></song>
<song id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></song>
</topSongs>
</subsonic-response>

View File

@ -150,10 +150,11 @@ type Child struct {
*/
// OpenSubsonic extensions
Played *time.Time `xml:"played,attr,omitempty" json:"played,omitempty"`
MediaType MediaType `xml:"mediaType,attr" json:"mediaType"`
MusicBrainzId string `xml:"musicBrainzId,attr" json:"musicBrainzId"`
Bpm int32 `xml:"bpm,attr" json:"bpm"`
Comment string `xml:"comment,attr" json:"comment"`
SortName string `xml:"sortName,attr" json:"sortName"`
MediaType MediaType `xml:"mediaType,attr" json:"mediaType"`
MusicBrainzId string `xml:"musicBrainzId,attr" json:"musicBrainzId"`
Genres ItemGenres `xml:"genres" json:"genres"`
}
@ -195,7 +196,10 @@ type ArtistID3 struct {
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int32 `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
ArtistImageUrl string `xml:"artistImageUrl,attr,omitempty" json:"artistImageUrl,omitempty"`
MusicBrainzId string `xml:"musicBrainzId,attr,omitempty" json:"musicBrainzId,omitempty"`
// OpenSubsonic extensions
MusicBrainzId string `xml:"musicBrainzId,attr,omitempty" json:"musicBrainzId,omitempty"`
SortName string `xml:"sortName,attr,omitempty" json:"sortName,omitempty"`
}
type AlbumID3 struct {
@ -217,6 +221,8 @@ type AlbumID3 struct {
UserRating int32 `xml:"userRating,attr" json:"userRating"`
Genres ItemGenres `xml:"genres" json:"genres"`
MusicBrainzId string `xml:"musicBrainzId,attr" json:"musicBrainzId"`
IsCompilation bool `xml:"isCompilation,attr" json:"isCompilation"`
SortName string `xml:"sortName,attr" json:"sortName"`
}
type ArtistWithAlbumsID3 struct {

View File

@ -171,8 +171,11 @@ var _ = Describe("Responses", func() {
Context("with data", func() {
BeforeEach(func() {
album := AlbumID3{Id: "1", Name: "album", Artist: "artist", Genre: "rock",
Genres: []ItemGenre{{Name: "rock"}, {Name: "progressive"}}, MusicBrainzId: "1234"}
album := AlbumID3{
Id: "1", Name: "album", Artist: "artist", Genre: "rock",
Genres: []ItemGenre{{Name: "rock"}, {Name: "progressive"}},
MusicBrainzId: "1234", IsCompilation: true, SortName: "sorted album",
}
t := time.Date(2016, 03, 2, 20, 30, 0, 0, time.UTC)
songs := []Child{{
Id: "1", IsDir: true, Title: "title", Album: "album", Artist: "artist", Track: 1,
@ -180,6 +183,7 @@ var _ = Describe("Responses", func() {
Suffix: "flac", TranscodedContentType: "audio/mpeg", TranscodedSuffix: "mp3",
Duration: 146, BitRate: 320, Starred: &t, Genres: []ItemGenre{{Name: "rock"}, {Name: "progressive"}},
Comment: "a comment", Bpm: 127, MediaType: MediaTypeSong, MusicBrainzId: "4321",
SortName: "sorted song",
}}
response.AlbumWithSongsID3.AlbumID3 = album
response.AlbumWithSongsID3.Song = songs