feat(subsonic): improve getArtistInfo2.view similar artist results (#203)
Co-authored-by: xavier <xavier@futurae.com>
This commit is contained in:
@@ -296,7 +296,12 @@ func (c *Controller) ServeGetArtistInfoTwo(r *http.Request) *spec.Response {
|
|||||||
|
|
||||||
count := params.GetOrInt("count", 20)
|
count := params.GetOrInt("count", 20)
|
||||||
inclNotPresent := params.GetOrBool("includeNotPresent", false)
|
inclNotPresent := params.GetOrBool("includeNotPresent", false)
|
||||||
for i, similarInfo := range info.Similar.Artists {
|
similarArtists, err := lastfm.ArtistGetSimilar(apiKey, artist.Name)
|
||||||
|
if err != nil {
|
||||||
|
return spec.NewError(0, "fetching artist similar: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, similarInfo := range similarArtists.Artists {
|
||||||
if i == count {
|
if i == count {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -311,16 +316,15 @@ func (c *Controller) ServeGetArtistInfoTwo(r *http.Request) *spec.Response {
|
|||||||
if errors.Is(err, gorm.ErrRecordNotFound) && !inclNotPresent {
|
if errors.Is(err, gorm.ErrRecordNotFound) && !inclNotPresent {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
similar := &spec.SimilarArtist{
|
artistID := &specid.ID{}
|
||||||
ID: &specid.ID{},
|
|
||||||
}
|
|
||||||
if artist.ID != 0 {
|
if artist.ID != 0 {
|
||||||
similar.ID = artist.SID()
|
artistID = artist.SID()
|
||||||
}
|
}
|
||||||
similar.Name = similarInfo.Name
|
sub.ArtistInfoTwo.SimilarArtist = append(sub.ArtistInfoTwo.SimilarArtist, &spec.SimilarArtist{
|
||||||
similar.AlbumCount = artist.AlbumCount
|
ID: artistID,
|
||||||
sub.ArtistInfoTwo.SimilarArtist = append(
|
Name: similarInfo.Name,
|
||||||
sub.ArtistInfoTwo.SimilarArtist, similar)
|
AlbumCount: artist.AlbumCount,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return sub
|
return sub
|
||||||
|
|||||||
Reference in New Issue
Block a user