🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Add userRating to Subsonic API's Artist
Deluan078a7c24e69f
diff --git a/server/subsonic/browsing.go b/server/subsonic/browsing.goindex 1428a520f..85e5f0620 100644--- a/server/subsonic/browsing.go+++ b/server/subsonic/browsing.go@@ -267,6 +267,7 @@ func (c *BrowsingController) GetArtistInfo(w http.ResponseWriter, r *http.Requesif s.Starred {similar.Starred = &s.StarredAt}+ similar.UserRating = s.Ratingresponse.ArtistInfo.SimilarArtist = append(response.ArtistInfo.SimilarArtist, similar)}return response, nildiff --git a/server/subsonic/engine/common.go b/server/subsonic/engine/common.goindex 0b2de0479..239adcb39 100644--- a/server/subsonic/engine/common.go+++ b/server/subsonic/engine/common.go@@ -51,6 +51,7 @@ func FromArtist(ar *model.Artist) Entry {e.Title = ar.Namee.AlbumCount = ar.AlbumCounte.IsDir = true+ e.UserRating = ar.Ratingif ar.Starred {e.Starred = ar.StarredAt}diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.goindex 4eb817fc7..a3d69eb5d 100644--- a/server/subsonic/helpers.go+++ b/server/subsonic/helpers.go@@ -89,6 +89,7 @@ func toArtists(entries engine.Entries) []responses.Artist {Id: entry.Id,Name: entry.Title,AlbumCount: entry.AlbumCount,+ UserRating: entry.UserRating,}if !entry.Starred.IsZero() {artists[i].Starred = &entry.Starreddiff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSONindex 800283f4d..976c93bc0 100644--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSON+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSON@@ -1 +1 @@-{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","indexes":{"index":[{"name":"A","artist":[{"id":"111","name":"aaa","starred":"2016-03-02T20:30:00Z"}]}],"lastModified":1,"ignoredArticles":"A"}}+{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","indexes":{"index":[{"name":"A","artist":[{"id":"111","name":"aaa","albumCount":2,"starred":"2016-03-02T20:30:00Z","userRating":3}]}],"lastModified":1,"ignoredArticles":"A"}}diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .XMLindex cf47d9e49..7b8bfee3b 100644--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .XML+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .XML@@ -1 +1 @@-<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><indexes lastModified="1" ignoredArticles="A"><index name="A"><artist id="111" name="aaa" starred="2016-03-02T20:30:00Z"></artist></index></indexes></subsonic-response>+<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><indexes lastModified="1" ignoredArticles="A"><index name="A"><artist id="111" name="aaa" albumCount="2" starred="2016-03-02T20:30:00Z" userRating="3"></artist></index></indexes></subsonic-response>diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.goindex af840de63..65736ec55 100644--- a/server/subsonic/responses/responses.go+++ b/server/subsonic/responses/responses.go@@ -73,8 +73,8 @@ type Artist struct {Name string `xml:"name,attr" json:"name"`AlbumCount int `xml:"albumCount,attr,omitempty" json:"albumCount,omitempty"`Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`+ UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`/*- <xs:attribute name="userRating" type="sub:UserRating" use="optional"/> <!-- Added in 1.13.0 --><xs:attribute name="averageRating" type="sub:AverageRating" use="optional"/> <!-- Added in 1.13.0 -->*/}@@ -123,8 +123,6 @@ type Child struct {BookmarkPosition int64 `xml:"bookmarkPosition,attr,omitempty" json:"bookmarkPosition,omitempty"`/*<xs:attribute name="averageRating" type="sub:AverageRating" use="optional"/> <!-- Added in 1.6.0 -->- <xs:attribute name="originalWidth" type="xs:int" use="optional"/> <!-- Added in 1.13.0 -->- <xs:attribute name="originalHeight" type="xs:int" use="optional"/> <!-- Added in 1.13.0 -->*/}diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.goindex cfe92275e..33fa6e8f9 100644--- a/server/subsonic/responses/responses_test.go+++ b/server/subsonic/responses/responses_test.go@@ -92,7 +92,7 @@ var _ = Describe("Responses", func() {BeforeEach(func() {artists := make([]Artist, 1)t := time.Date(2016, 03, 2, 20, 30, 0, 0, time.UTC)- artists[0] = Artist{Id: "111", Name: "aaa", Starred: &t}+ artists[0] = Artist{Id: "111", Name: "aaa", Starred: &t, UserRating: 3, AlbumCount: 2}index := make([]Index, 1)index[0] = Index{Name: "A", Artists: artists}response.Indexes.Index = indexdiff --git a/server/subsonic/searching.go b/server/subsonic/searching.goindex a2b0cf727..9fddb830c 100644--- a/server/subsonic/searching.go+++ b/server/subsonic/searching.go@@ -83,6 +83,7 @@ func (c *SearchingController) Search2(w http.ResponseWriter, r *http.Request) (*Id: artist.ID,Name: artist.Name,AlbumCount: artist.AlbumCount,+ UserRating: artist.Rating,}if artist.Starred {searchResult2.Artist[i].Starred = &artist.StarredAt