@@ -32,6 +32,7 @@
3232#include <QByteArray>
3333#include <QImage>
3434#include <QUrl>
35+#include <QUrlQuery>
3536
3637using namespace std;
3738
@@ -65,6 +66,9 @@ AlbumArtProvider::~AlbumArtProvider()
6566std::string AlbumArtProvider::get_lastfm_url(const albuminfo &ai) {
6667 QString artist = QString::fromStdString(ai.artist);
6768 QString album = QString::fromStdString(ai.album);
69+ // audioscrobbler wants it without any / (as it would break the URL)
70+ artist.remove('/');
71+ album.remove('/');
6872
6973 /// @todo: this is the old API which will probably get axed at some point in the future
7074 /// The new 2.0 API requires an API key, but supports JSON output, etc, so switching
@@ -200,21 +204,20 @@ std::string AlbumArtProvider::get_image(const std::string &artist, const std::st
200204QImage AlbumArtProvider::requestImage(const QString &id, QSize *realSize, const QSize &requestedSize) {
201205 Q_UNUSED(requestedSize)
202206
203− const QStringList parts = id.split("/");
204− if (parts.size() != 2) {
207+ QUrlQuery query(id);
208+ if (!query.hasQueryItem(QStringLiteral("artist")) || !query.hasQueryItem(QStringLiteral("album"))) {
205209 qWarning() << "Invalid albumart uri:" << id;
206210 return QImage(QString::fromStdString(DEFAULT_ALBUM_ART));
207211 }
208− const std::string artist = QUrl::fromPercentEncoding(parts[0].toUtf8()).toStdString();
209− const std::string album = QUrl::fromPercentEncoding(parts[1].toUtf8()).toStdString();
212+ const QString artist = query.queryItemValue(QStringLiteral("artist"), QUrl::FullyEncoded);
213+ const QString album = query.queryItemValue(QStringLiteral("album"), QUrl::FullyEncoded);
210214
211215 std::string tgt_path;
212216 try {
213− tgt_path = get_image(artist, album);
217+ tgt_path = get_image(artist.toStdString(), album.toStdString());
214218 if(!tgt_path.empty()) {
215− QString tgt(tgt_path.c_str());
216219 QImage image;
217− image.load(tgt);
220+ image.load(QString::fromStdString(tgt_path));
218221 // FIXME: Rescale to requested size preserving aspect.
219222 *realSize = image.size();
220223 return image;