2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
2018-12-15 15:12:18 +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 MUSICBRAINZCOVERPROVIDER_H
|
|
|
|
#define MUSICBRAINZCOVERPROVIDER_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <QObject>
|
2018-12-15 15:12:18 +01:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <QVariant>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
2018-12-15 15:12:18 +01:00
|
|
|
#include <QJsonObject>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#include "coverprovider.h"
|
2018-12-15 15:12:18 +01:00
|
|
|
#include "albumcoverfetcher.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class MusicbrainzCoverProvider : public CoverProvider {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit MusicbrainzCoverProvider(QObject *parent = nullptr);
|
|
|
|
|
2018-12-15 15:12:18 +01:00
|
|
|
bool StartSearch(const QString &artist, const QString &album, int id);
|
|
|
|
void CancelSearch(int id);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
private slots:
|
2018-12-15 15:12:18 +01:00
|
|
|
void HandleSearchReply(QNetworkReply *reply, int search_id);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QByteArray GetReplyData(QNetworkReply *reply);
|
|
|
|
QJsonObject ExtractJsonObj(const QByteArray &data);
|
|
|
|
void Error(QString error, QVariant debug = QVariant());
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
private:
|
2018-09-01 22:21:45 +02:00
|
|
|
static const char *kReleaseSearchUrl;
|
|
|
|
static const char *kAlbumCoverUrl;
|
2018-12-15 15:12:18 +01:00
|
|
|
static const int kLimit;
|
2018-02-27 18:06:05 +01:00
|
|
|
QNetworkAccessManager *network_;
|
2018-03-05 21:05:30 +01:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MUSICBRAINZCOVERPROVIDER_H
|