Skip to content

Commit

Permalink
#182: switch back to GetArtistInfo2 and add defensive nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed May 31, 2023
1 parent 066be7b commit 2869672
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions backend/mediaprovider/subsonic/subsonicmediaprovider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package subsonic

import (
"errors"
"image"
"math"
"strconv"
Expand Down Expand Up @@ -74,15 +75,18 @@ func (s *subsonicMediaProvider) GetArtist(artistID string) (*mediaprovider.Artis
}

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 {
return nil, err
}
if info == nil {
return nil, errors.New("server returned empty artist info")
}
return &mediaprovider.ArtistInfo{
Biography: info.Biography,
LastFMUrl: info.LastFmUrl,
ImageURL: info.LargeImageUrl,
SimilarArtists: sharedutil.MapSlice(info.SimilarArtist, toArtist),
SimilarArtists: sharedutil.MapSlice(info.SimilarArtist, toArtistFromID3),
}, nil
}

Expand Down Expand Up @@ -294,17 +298,6 @@ func fillAlbum(subAlbum *subsonic.AlbumID3, album *mediaprovider.Album) {
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 {
if ar == nil {
return nil
Expand Down

0 comments on commit 2869672

Please sign in to comment.