From 83f17a37b187bb2ddfeaaa0b14719afedd34eb20 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 13 Oct 2020 01:38:09 +0200 Subject: [PATCH] Use format only when available --- src/qobuz/qobuzrequest.cpp | 9 +++------ src/subsonic/subsonicrequest.cpp | 10 ++++++++-- src/tidal/tidalrequest.cpp | 9 +++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/qobuz/qobuzrequest.cpp b/src/qobuz/qobuzrequest.cpp index 40d3dd323..8234cad4a 100644 --- a/src/qobuz/qobuzrequest.cpp +++ b/src/qobuz/qobuzrequest.cpp @@ -1249,12 +1249,9 @@ void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_ur } QList format_list = Utilities::ImageFormatsForMimeType(mimetype.toUtf8()); - QByteArray format; - if (format_list.isEmpty()) { - format = "JPG"; - } - else { - format = format_list.first(); + char *format = nullptr; + if (!format_list.isEmpty()) { + format = format_list.first().data(); } QImage image; diff --git a/src/subsonic/subsonicrequest.cpp b/src/subsonic/subsonicrequest.cpp index 6851bc21a..f73045e9c 100644 --- a/src/subsonic/subsonicrequest.cpp +++ b/src/subsonic/subsonicrequest.cpp @@ -803,9 +803,15 @@ void SubsonicRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl url, c return; } + QList format_list = Utilities::ImageFormatsForMimeType(mimetype.toUtf8()); + char *format = nullptr; + if (!format_list.isEmpty()) { + format = format_list.first().data(); + } + QImage image; - if (image.loadFromData(data)) { - if (image.save(filename, "JPG")) { + if (image.loadFromData(data, format)) { + if (image.save(filename, format)) { while (album_covers_requests_sent_.contains(url)) { Song *song = album_covers_requests_sent_.take(url); song->set_art_automatic(QUrl::fromLocalFile(filename)); diff --git a/src/tidal/tidalrequest.cpp b/src/tidal/tidalrequest.cpp index 6497fbb6b..134f500d8 100644 --- a/src/tidal/tidalrequest.cpp +++ b/src/tidal/tidalrequest.cpp @@ -1186,12 +1186,9 @@ void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &album } QList format_list = Utilities::ImageFormatsForMimeType(mimetype.toUtf8()); - QByteArray format; - if (format_list.isEmpty()) { - format = "JPG"; - } - else { - format = format_list.first(); + char *format = nullptr; + if (!format_list.isEmpty()) { + format = format_list.first().data(); } QImage image;