mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-03 13:30:26 +01:00
Cope with empty spotify image responses
This commit is contained in:
parent
1f95a23fd4
commit
deb1c638cc
@ -21,9 +21,7 @@ QString ExtractSpotifyId(const QString& spotify_uri) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SpotifyImages::SpotifyImages()
|
||||
: network_(new NetworkAccessManager) {
|
||||
}
|
||||
SpotifyImages::SpotifyImages() : network_(new NetworkAccessManager) {}
|
||||
|
||||
SpotifyImages::~SpotifyImages() {}
|
||||
|
||||
@ -82,13 +80,16 @@ void SpotifyImages::FetchImagesForArtist(int id, const QString& spotify_id) {
|
||||
QUrl url = image["url"].toUrl();
|
||||
image_candidates.append(qMakePair(url, QSize(width, height)));
|
||||
}
|
||||
QPair<QUrl, QSize> winner = *std::max_element(
|
||||
image_candidates.begin(),
|
||||
image_candidates.end(),
|
||||
[](const QPair<QUrl, QSize>& a, const QPair<QUrl, QSize>& b) {
|
||||
return (a.second.height() * a.second.width()) < (b.second.height() * b.second.width());
|
||||
});
|
||||
emit ImageReady(id, winner.first);
|
||||
if (!image_candidates.isEmpty()) {
|
||||
QPair<QUrl, QSize> winner =
|
||||
*std::max_element(
|
||||
image_candidates.begin(), image_candidates.end(),
|
||||
[](const QPair<QUrl, QSize>& a, const QPair<QUrl, QSize>& b) {
|
||||
return (a.second.height() * a.second.width()) <
|
||||
(b.second.height() * b.second.width());
|
||||
});
|
||||
emit ImageReady(id, winner.first);
|
||||
}
|
||||
emit Finished(id);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user