[spotify] Fix poor artwork resolution on playback from playlist start

Closes #1559
This commit is contained in:
ejurgensen 2022-12-21 17:39:41 +01:00
parent 82a5672d99
commit 5e7bf1826c

View File

@ -673,7 +673,7 @@ get_album_image(json_object *jsonalbum, int max_w)
int image_count;
int index;
int width;
int candidate_width = 0;
int candidate_width;
const char *artwork_url = NULL;
bool use_image;
@ -693,7 +693,7 @@ get_album_image(json_object *jsonalbum, int max_w)
// (widest image first), but at one point had a bug that meant they didn't, so
// we don't rely on that here.
image_count = json_object_array_length(jsonimages);
for (index = 0; index < image_count; index++)
for (index = 0, candidate_width = 0; index < image_count; index++)
{
jsonimage = json_object_array_get_idx(jsonimages, index);
if (!jsonimage)
@ -701,9 +701,10 @@ get_album_image(json_object *jsonalbum, int max_w)
width = jparse_int_from_obj(jsonimage, "width");
use_image =
((width <= max_w || max_w == 0 || candidate_width == 0) && width > candidate_width) ||
(width > max_w && candidate_width > width);
if (max_w == 0 || candidate_width == 0)
use_image = (width > candidate_width);
else
use_image = (width <= max_w && width > candidate_width) || (max_w < width && width < candidate_width);
if (!use_image)
continue;