Add userRating to Subsonic Album/Artist responses. Closes #1486

This commit is contained in:
Deluan
2021-11-23 21:50:57 -05:00
parent 6a1f9678b1
commit 30d3f1eda0
3 changed files with 18 additions and 13 deletions
+2
View File
@@ -267,6 +267,7 @@ func (c *BrowsingController) GetArtistInfo2(w http.ResponseWriter, r *http.Reque
similar.Name = s.Name similar.Name = s.Name
similar.AlbumCount = s.AlbumCount similar.AlbumCount = s.AlbumCount
similar.Starred = s.Starred similar.Starred = s.Starred
similar.UserRating = s.UserRating
similar.ArtistImageUrl = s.ArtistImageUrl similar.ArtistImageUrl = s.ArtistImageUrl
response.ArtistInfo2.SimilarArtist = append(response.ArtistInfo2.SimilarArtist, similar) response.ArtistInfo2.SimilarArtist = append(response.ArtistInfo2.SimilarArtist, similar)
} }
@@ -387,6 +388,7 @@ func (c *BrowsingController) buildAlbum(ctx context.Context, album *model.Album,
dir.PlayCount = album.PlayCount dir.PlayCount = album.PlayCount
dir.Year = album.MaxYear dir.Year = album.MaxYear
dir.Genre = album.Genre dir.Genre = album.Genre
dir.UserRating = album.Rating
if !album.CreatedAt.IsZero() { if !album.CreatedAt.IsZero() {
dir.Created = &album.CreatedAt dir.Created = &album.CreatedAt
} }
+1
View File
@@ -100,6 +100,7 @@ func toArtistID3(ctx context.Context, a model.Artist) responses.ArtistID3 {
Name: a.Name, Name: a.Name,
AlbumCount: a.AlbumCount, AlbumCount: a.AlbumCount,
ArtistImageUrl: a.ArtistImageUrl(), ArtistImageUrl: a.ArtistImageUrl(),
UserRating: a.Rating,
} }
if a.Starred { if a.Starred {
artist.Starred = &a.StarredAt artist.Starred = &a.StarredAt
+2
View File
@@ -165,6 +165,7 @@ type ArtistID3 struct {
CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"` CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
AlbumCount int `xml:"albumCount,attr,omitempty" json:"albumCount,omitempty"` AlbumCount int `xml:"albumCount,attr,omitempty" json:"albumCount,omitempty"`
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"` Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
ArtistImageUrl string `xml:"artistImageUrl,attr,omitempty" json:"artistImageUrl,omitempty"` ArtistImageUrl string `xml:"artistImageUrl,attr,omitempty" json:"artistImageUrl,omitempty"`
} }
@@ -179,6 +180,7 @@ type AlbumID3 struct {
PlayCount int64 `xml:"playCount,attr,omitempty" json:"playcount,omitempty"` PlayCount int64 `xml:"playCount,attr,omitempty" json:"playcount,omitempty"`
Created *time.Time `xml:"created,attr,omitempty" json:"created,omitempty"` Created *time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"` Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
Year int `xml:"year,attr,omitempty" json:"year,omitempty"` Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"` Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
} }