Add userRating to Subsonic API's Artist

This commit is contained in:
Deluan 2020-10-21 15:51:12 -04:00
parent 69e1059705
commit 078a7c24e6
8 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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"}}

View File

@ -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>

View File

@ -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 -->
*/
}

View File

@ -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

View File

@ -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