diff --git a/server/subsonic/browsing.go b/server/subsonic/browsing.go index 1428a520..85e5f062 100644 --- a/server/subsonic/browsing.go +++ b/server/subsonic/browsing.go @@ -267,6 +267,7 @@ func (c *BrowsingController) GetArtistInfo(w http.ResponseWriter, r *http.Reques if s.Starred { similar.Starred = &s.StarredAt } + similar.UserRating = s.Rating response.ArtistInfo.SimilarArtist = append(response.ArtistInfo.SimilarArtist, similar) } return response, nil diff --git a/server/subsonic/engine/common.go b/server/subsonic/engine/common.go index 0b2de047..239adcb3 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.Name e.AlbumCount = ar.AlbumCount e.IsDir = true + e.UserRating = ar.Rating if ar.Starred { e.Starred = ar.StarredAt } diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.go index 4eb817fc..a3d69eb5 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.Starred diff --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 .JSON index 800283f4..976c93bc 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 .XML index cf47d9e4..7b8bfee3 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 @@ - + diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.go index af840de6..65736ec5 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"` /* - */ } @@ -123,8 +123,6 @@ type Child struct { BookmarkPosition int64 `xml:"bookmarkPosition,attr,omitempty" json:"bookmarkPosition,omitempty"` /* - - */ } diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.go index cfe92275..33fa6e8f 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 = index diff --git a/server/subsonic/searching.go b/server/subsonic/searching.go index a2b0cf72..9fddb830 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