@@ -32,6 +32,7 @@
32#include <QByteArray>
32#include <QByteArray>
33#include <QImage>
33#include <QImage>
34#include <QUrl>
34#include <QUrl>
36using namespace std;
37using namespace std;
@@ -65,6 +66,9 @@ AlbumArtProvider::~AlbumArtProvider()
65std::string AlbumArtProvider::get_lastfm_url(const albuminfo &ai) {
66std::string AlbumArtProvider::get_lastfm_url(const albuminfo &ai) {
66 QString artist = QString::fromStdString(ai.artist);
67 QString artist = QString::fromStdString(ai.artist);
67 QString album = QString::fromStdString(ai.album);
68 QString album = QString::fromStdString(ai.album);
69+ // audioscrobbler wants it without any / (as it would break the URL)
69 /// @todo: this is the old API which will probably get axed at some point in the future
73 /// @todo: this is the old API which will probably get axed at some point in the future
70 /// The new 2.0 API requires an API key, but supports JSON output, etc, so switching
74 /// 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
200QImage AlbumArtProvider::requestImage(const QString &id, QSize *realSize, const QSize &requestedSize) {
204QImage AlbumArtProvider::requestImage(const QString &id, QSize *realSize, const QSize &requestedSize) {
201 Q_UNUSED(requestedSize)
205 Q_UNUSED(requestedSize)
203− const QStringList parts = id.split("/");
207+ QUrlQuery query(id);
204− if (parts.size() != 2) {
208+ if (!query.hasQueryItem(QStringLiteral("artist")) || !query.hasQueryItem(QStringLiteral("album"))) {
205 qWarning() << "Invalid albumart uri:" << id;
209 qWarning() << "Invalid albumart uri:" << id;
206 return QImage(QString::fromStdString(DEFAULT_ALBUM_ART));
210 return QImage(QString::fromStdString(DEFAULT_ALBUM_ART));
208− const std::string artist = QUrl::fromPercentEncoding(parts[0].toUtf8()).toStdString();
212+ const QString artist = query.queryItemValue(QStringLiteral("artist"), QUrl::FullyEncoded);
209− const std::string album = QUrl::fromPercentEncoding(parts[1].toUtf8()).toStdString();
213+ const QString album = query.queryItemValue(QStringLiteral("album"), QUrl::FullyEncoded);
211 std::string tgt_path;
215 std::string tgt_path;
213− tgt_path = get_image(artist, album);
217+ tgt_path = get_image(artist.toStdString(), album.toStdString());
214 if(!tgt_path.empty()) {
218 if(!tgt_path.empty()) {
215− QString tgt(tgt_path.c_str());
216 QImage image;
219 QImage image;
217− image.load(tgt);
220+ image.load(QString::fromStdString(tgt_path));
218 // FIXME: Rescale to requested size preserving aspect.
221 // FIXME: Rescale to requested size preserving aspect.
219 *realSize = image.size();
222 *realSize = image.size();
220 return image;
223 return image;