strawberry-audio-player-win.../src/covermanager/lastfmcoverprovider.h

70 lines
1.8 KiB
C
Raw Normal View History

2018-02-27 18:06:05 +01:00
/*
* Strawberry Music Player
2018-12-15 00:43:50 +01:00
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
2018-02-27 18:06:05 +01:00
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
2018-08-09 18:39:44 +02:00
*
2018-02-27 18:06:05 +01:00
*/
#ifndef LASTFMCOVERPROVIDER_H
#define LASTFMCOVERPROVIDER_H
#include "config.h"
#include <QObject>
2018-12-15 00:52:58 +01:00
#include <QVariant>
#include <QByteArray>
#include <QString>
2018-12-15 00:52:58 +01:00
#include <QJsonValue>
#include <QJsonObject>
2018-02-27 18:06:05 +01:00
#include "coverprovider.h"
2018-02-27 18:06:05 +01:00
2020-02-09 02:29:35 +01:00
class QNetworkAccessManager;
class QNetworkReply;
2019-04-14 16:40:05 +02:00
class Application;
2018-02-27 18:06:05 +01:00
class LastFmCoverProvider : public CoverProvider {
Q_OBJECT
public:
2019-04-14 16:40:05 +02:00
explicit LastFmCoverProvider(Application *app, QObject *parent = nullptr);
2019-09-15 20:27:32 +02:00
bool StartSearch(const QString &artist, const QString &album, const int id);
private slots:
2019-09-15 20:27:32 +02:00
void QueryFinished(QNetworkReply *reply, const int id);
2018-02-27 18:06:05 +01:00
private:
2018-12-15 00:43:50 +01:00
static const char *kUrl;
static const char *kApiKey;
static const char *kSecret;
enum LastFmImageSize {
Unknown,
Small,
Medium,
Large,
ExtraLarge
};
QByteArray GetReplyData(QNetworkReply *reply);
QJsonObject ExtractJsonObj(const QByteArray &data);
QJsonValue ExtractResults(const QByteArray &data);
2019-09-15 20:27:32 +02:00
LastFmImageSize ImageSizeFromString(const QString &size);
void Error(const QString &error, const QVariant &debug = QVariant());
2018-12-15 00:43:50 +01:00
2018-02-27 18:06:05 +01:00
QNetworkAccessManager *network_;
2018-02-27 18:06:05 +01:00
};
2018-12-15 00:43:50 +01:00
#endif // LASTFMCOVERPROVIDER_H