🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Add ReplayGain to OpenSubsonic API Child response
Deluan4641dc0b2bbd
diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.goindex 1d10ea23d..0f4ab4a6a 100644--- a/server/subsonic/helpers.go+++ b/server/subsonic/helpers.go@@ -192,6 +192,12 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Childchild.Bpm = int32(mf.Bpm)child.MediaType = responses.MediaTypeSongchild.MusicBrainzId = mf.MbzRecordingID+ child.ReplayGain = responses.ReplayGain{+ TrackGain: mf.RGTrackGain,+ AlbumGain: mf.RGAlbumGain,+ TrackPeak: mf.RGTrackPeak,+ AlbumPeak: mf.RGAlbumPeak,+ }return child}diff --git a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSONindex a2dd3a7ea..2d3bc3b7c 100644--- a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON@@ -16,7 +16,8 @@"sortName": "","mediaType": "","musicBrainzId": "",- "genres": []+ "genres": [],+ "replayGain": {}}]}diff --git a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XMLindex 549d7a17c..8787b4239 100644--- a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML@@ -1,5 +1,7 @@<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" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></album>+ <album id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId="">+ <replayGain></replayGain>+ </album></albumList></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSONindex 6a6d74e6b..da546b70b 100644--- a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON@@ -53,7 +53,15 @@{"name": "progressive"}- ]+ ],+ "replayGain": {+ "trackGain": 1,+ "albumGain": 2,+ "trackPeak": 3,+ "albumPeak": 4,+ "baseGain": 5,+ "fallbackGain": 6+ }}]}diff --git a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XMLindex b329443e9..535393582 100644--- a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML@@ -5,6 +5,7 @@<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>+ <replayGain trackGain="1" albumGain="2" trackPeak="3" albumPeak="4" baseGain="5" fallbackGain="6"></replayGain></song></album></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSONindex 8f0ac4f95..3edf0cfd5 100644--- a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON@@ -17,7 +17,8 @@"sortName": "","mediaType": "","musicBrainzId": "",- "genres": []+ "genres": [],+ "replayGain": {}},"position": 123,"username": "user2",diff --git a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XMLindex f3bfe4112..db7c67102 100644--- a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML@@ -1,7 +1,9 @@<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" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></entry>+ <entry id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId="">+ <replayGain></replayGain>+ </entry></bookmark></bookmarks></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Child with data should match .JSONindex 9c169f3b7..8abef4a64 100644--- a/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON@@ -37,7 +37,15 @@{"name": "progressive"}- ]+ ],+ "replayGain": {+ "trackGain": 1,+ "albumGain": 2,+ "trackPeak": 3,+ "albumPeak": 4,+ "baseGain": 5,+ "fallbackGain": 6+ }}],"id": "1",diff --git a/server/subsonic/responses/.snapshots/Responses Child with data should match .XML b/server/subsonic/responses/.snapshots/Responses Child with data should match .XMLindex 28f2559b2..fe858081f 100644--- a/server/subsonic/responses/.snapshots/Responses Child with data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses Child with data should match .XML@@ -3,6 +3,7 @@<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>+ <replayGain trackGain="1" albumGain="2" trackPeak="3" albumPeak="4" baseGain="5" fallbackGain="6"></replayGain></child></directory></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON b/server/subsonic/responses/.snapshots/Responses Child without data should match .JSONindex ba8b9fdbc..57cf62d39 100644--- a/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON@@ -15,7 +15,8 @@"sortName": "","mediaType": "","musicBrainzId": "",- "genres": []+ "genres": [],+ "replayGain": {}}],"id": "",diff --git a/server/subsonic/responses/.snapshots/Responses Child without data should match .XML b/server/subsonic/responses/.snapshots/Responses Child without data should match .XMLindex f00a262a8..aa1636899 100644--- a/server/subsonic/responses/.snapshots/Responses Child without data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses Child without data should match .XML@@ -1,5 +1,7 @@<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" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></child>+ <child id="1" isDir="false" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId="">+ <replayGain></replayGain>+ </child></directory></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSONindex 50515bde9..6d16805c6 100644--- a/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON@@ -16,7 +16,8 @@"sortName": "","mediaType": "","musicBrainzId": "",- "genres": []+ "genres": [],+ "replayGain": {}}],"id": "1",diff --git a/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML b/server/subsonic/responses/.snapshots/Responses Directory with data should match .XMLindex ee2083724..11c9b381a 100644--- a/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML@@ -1,5 +1,7 @@<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" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></child>+ <child id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId="">+ <replayGain></replayGain>+ </child></directory></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSONindex 3d299be63..42ea7de59 100644--- a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON@@ -16,7 +16,8 @@"sortName": "","mediaType": "","musicBrainzId": "",- "genres": []+ "genres": [],+ "replayGain": {}}],"current": "111",diff --git a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XMLindex 0b9211576..c37f61698 100644--- a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML@@ -1,5 +1,7 @@<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" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></entry>+ <entry id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId="">+ <replayGain></replayGain>+ </entry></playQueue></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSONindex 8fa03c3b3..34af86c26 100644--- a/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON@@ -21,7 +21,8 @@"sortName": "","mediaType": "","musicBrainzId": "",- "genres": []+ "genres": [],+ "replayGain": {}},{"id": "2",@@ -36,7 +37,8 @@"sortName": "","mediaType": "","musicBrainzId": "",- "genres": []+ "genres": [],+ "replayGain": {}}],"id": "ABC123",diff --git a/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML b/server/subsonic/responses/.snapshots/Responses Shares with data should match .XMLindex 18a2b6ff4..d8863b6d8 100644--- a/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML@@ -1,8 +1,12 @@<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" 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>+ <entry id="1" isDir="false" title="title" album="album" artist="artist" duration="120" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId="">+ <replayGain></replayGain>+ </entry>+ <entry id="2" isDir="false" title="title 2" album="album" artist="artist" duration="300" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId="">+ <replayGain></replayGain>+ </entry></share></shares></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSONindex 51951b04e..7a42f091c 100644--- a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON@@ -16,7 +16,8 @@"sortName": "","mediaType": "","musicBrainzId": "",- "genres": []+ "genres": [],+ "replayGain": {}}]}diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XMLindex 9ef47632f..78c41a770 100644--- a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML@@ -1,5 +1,7 @@<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" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></song>+ <song id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId="">+ <replayGain></replayGain>+ </song></similarSongs></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSONindex b4cb7aced..74b6c2323 100644--- a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON@@ -16,7 +16,8 @@"sortName": "","mediaType": "","musicBrainzId": "",- "genres": []+ "genres": [],+ "replayGain": {}}]}diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XMLindex faac7083d..bf98df70b 100644--- a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML@@ -1,5 +1,7 @@<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" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></song>+ <song id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId="">+ <replayGain></replayGain>+ </song></similarSongs2></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSONindex 0c3a9c53f..226b4ab13 100644--- a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON+++ b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON@@ -16,7 +16,8 @@"sortName": "","mediaType": "","musicBrainzId": "",- "genres": []+ "genres": [],+ "replayGain": {}}]}diff --git a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XMLindex 1daf29044..3a5977984 100644--- a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML+++ b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML@@ -1,5 +1,7 @@<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" bpm="0" comment="" sortName="" mediaType="" musicBrainzId=""></song>+ <song id="1" isDir="false" title="title" isVideo="false" bpm="0" comment="" sortName="" mediaType="" musicBrainzId="">+ <replayGain></replayGain>+ </song></topSongs></subsonic-response>diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.goindex 6c74936d1..04bac482a 100644--- a/server/subsonic/responses/responses.go+++ b/server/subsonic/responses/responses.go@@ -156,6 +156,7 @@ type Child struct {MediaType MediaType `xml:"mediaType,attr" json:"mediaType"`MusicBrainzId string `xml:"musicBrainzId,attr" json:"musicBrainzId"`Genres ItemGenres `xml:"genres" json:"genres"`+ ReplayGain ReplayGain `xml:"replayGain" json:"replayGain"`}type Songs struct {@@ -465,3 +466,12 @@ func (i ItemGenres) MarshalJSON() ([]byte, error) {a := (Alias)(i)return json.Marshal(a)}++type ReplayGain struct {+ TrackGain float64 `xml:"trackGain,omitempty,attr" json:"trackGain,omitempty"`+ AlbumGain float64 `xml:"albumGain,omitempty,attr" json:"albumGain,omitempty"`+ TrackPeak float64 `xml:"trackPeak,omitempty,attr" json:"trackPeak,omitempty"`+ AlbumPeak float64 `xml:"albumPeak,omitempty,attr" json:"albumPeak,omitempty"`+ BaseGain float64 `xml:"baseGain,omitempty,attr" json:"baseGain,omitempty"`+ FallbackGain float64 `xml:"fallbackGain,omitempty,attr" json:"fallbackGain,omitempty"`+}diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.goindex 832214790..23f1abaf0 100644--- a/server/subsonic/responses/responses_test.go+++ b/server/subsonic/responses/responses_test.go@@ -143,6 +143,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",+ ReplayGain: ReplayGain{TrackGain: 1, AlbumGain: 2, TrackPeak: 3, AlbumPeak: 4, BaseGain: 5, FallbackGain: 6},}response.Directory.Child = child})@@ -182,8 +183,8 @@ var _ = Describe("Responses", func() {Year: 1985, Genre: "Rock", CoverArt: "1", Size: 8421341, ContentType: "audio/flac",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",+ Comment: "a comment", Bpm: 127, MediaType: MediaTypeSong, MusicBrainzId: "4321", SortName: "sorted song",+ ReplayGain: ReplayGain{TrackGain: 1, AlbumGain: 2, TrackPeak: 3, AlbumPeak: 4, BaseGain: 5, FallbackGain: 6},}}response.AlbumWithSongsID3.AlbumID3 = albumresponse.AlbumWithSongsID3.Song = songs