#182: switch back to GetArtistInfo2 and add defensive nil check
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package subsonic
|
package subsonic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"image"
|
"image"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -74,15 +75,18 @@ func (s *subsonicMediaProvider) GetArtist(artistID string) (*mediaprovider.Artis
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *subsonicMediaProvider) GetArtistInfo(artistID string) (*mediaprovider.ArtistInfo, error) {
|
func (s *subsonicMediaProvider) GetArtistInfo(artistID string) (*mediaprovider.ArtistInfo, error) {
|
||||||
info, err := s.client.GetArtistInfo(artistID, map[string]string{})
|
info, err := s.client.GetArtistInfo2(artistID, map[string]string{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if info == nil {
|
||||||
|
return nil, errors.New("server returned empty artist info")
|
||||||
|
}
|
||||||
return &mediaprovider.ArtistInfo{
|
return &mediaprovider.ArtistInfo{
|
||||||
Biography: info.Biography,
|
Biography: info.Biography,
|
||||||
LastFMUrl: info.LastFmUrl,
|
LastFMUrl: info.LastFmUrl,
|
||||||
ImageURL: info.LargeImageUrl,
|
ImageURL: info.LargeImageUrl,
|
||||||
SimilarArtists: sharedutil.MapSlice(info.SimilarArtist, toArtist),
|
SimilarArtists: sharedutil.MapSlice(info.SimilarArtist, toArtistFromID3),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,17 +298,6 @@ func fillAlbum(subAlbum *subsonic.AlbumID3, album *mediaprovider.Album) {
|
|||||||
album.Favorite = !subAlbum.Starred.IsZero()
|
album.Favorite = !subAlbum.Starred.IsZero()
|
||||||
}
|
}
|
||||||
|
|
||||||
func toArtist(ar *subsonic.Artist) *mediaprovider.Artist {
|
|
||||||
if ar == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &mediaprovider.Artist{
|
|
||||||
ID: ar.ID,
|
|
||||||
Name: ar.Name,
|
|
||||||
Favorite: !ar.Starred.IsZero(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func toArtistFromID3(ar *subsonic.ArtistID3) *mediaprovider.Artist {
|
func toArtistFromID3(ar *subsonic.ArtistID3) *mediaprovider.Artist {
|
||||||
if ar == nil {
|
if ar == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user