From 50d6b4730edb3f46e9286b4aaa66574178723c71 Mon Sep 17 00:00:00 2001 From: will <39891237+william-matz@users.noreply.github.com> Date: Thu, 3 Aug 2023 15:24:15 -0400 Subject: [PATCH] fix: return large avatar url from spotify --- internal/api/provider/spotify.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/api/provider/spotify.go b/internal/api/provider/spotify.go index f278c3ff3e..bdac816047 100644 --- a/internal/api/provider/spotify.go +++ b/internal/api/provider/spotify.go @@ -80,8 +80,17 @@ func (g spotifyProvider) GetUserData(ctx context.Context, tok *oauth2.Token) (*U var avatarURL string + // Spotify returns a list of avatars, we want to use the largest one if len(u.Avatars) >= 1 { - avatarURL = u.Avatars[0].Url + largestAvatar := u.Avatars[0] + + for _, avatar := range u.Avatars { + if avatar.Height * avatar.Width > largestAvatar.Height * largestAvatar.Width { + largestAvatar = avatar + } + } + + avatarURL = largestAvatar.Url } return &UserProvidedData{