mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-02 10:36:45 +01:00
Reduce network access managers
This commit is contained in:
parent
f2d52f83fe
commit
e6858719c9
@ -128,17 +128,17 @@ class ApplicationImpl {
|
|||||||
cover_providers_([=]() {
|
cover_providers_([=]() {
|
||||||
CoverProviders *cover_providers = new CoverProviders(app);
|
CoverProviders *cover_providers = new CoverProviders(app);
|
||||||
// Initialize the repository of cover providers.
|
// Initialize the repository of cover providers.
|
||||||
cover_providers->AddProvider(new LastFmCoverProvider(app, app));
|
cover_providers->AddProvider(new LastFmCoverProvider(app, cover_providers->network(), app));
|
||||||
cover_providers->AddProvider(new MusicbrainzCoverProvider(app, app));
|
cover_providers->AddProvider(new MusicbrainzCoverProvider(app, cover_providers->network(), app));
|
||||||
cover_providers->AddProvider(new DiscogsCoverProvider(app, app));
|
cover_providers->AddProvider(new DiscogsCoverProvider(app, cover_providers->network(), app));
|
||||||
cover_providers->AddProvider(new DeezerCoverProvider(app, app));
|
cover_providers->AddProvider(new DeezerCoverProvider(app, cover_providers->network(), app));
|
||||||
cover_providers->AddProvider(new MusixmatchCoverProvider(app, app));
|
cover_providers->AddProvider(new MusixmatchCoverProvider(app, cover_providers->network(), app));
|
||||||
cover_providers->AddProvider(new SpotifyCoverProvider(app, app));
|
cover_providers->AddProvider(new SpotifyCoverProvider(app, cover_providers->network(), app));
|
||||||
#ifdef HAVE_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
cover_providers->AddProvider(new TidalCoverProvider(app, app));
|
cover_providers->AddProvider(new TidalCoverProvider(app, cover_providers->network(), app));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_QOBUZ
|
#ifdef HAVE_QOBUZ
|
||||||
cover_providers->AddProvider(new QobuzCoverProvider(app, app));
|
cover_providers->AddProvider(new QobuzCoverProvider(app, cover_providers->network(), app));
|
||||||
#endif
|
#endif
|
||||||
cover_providers->ReloadSettings();
|
cover_providers->ReloadSettings();
|
||||||
return cover_providers;
|
return cover_providers;
|
||||||
@ -152,12 +152,12 @@ class ApplicationImpl {
|
|||||||
lyrics_providers_([=]() {
|
lyrics_providers_([=]() {
|
||||||
LyricsProviders *lyrics_providers = new LyricsProviders(app);
|
LyricsProviders *lyrics_providers = new LyricsProviders(app);
|
||||||
// Initialize the repository of lyrics providers.
|
// Initialize the repository of lyrics providers.
|
||||||
lyrics_providers->AddProvider(new AuddLyricsProvider(app));
|
lyrics_providers->AddProvider(new AuddLyricsProvider(lyrics_providers->network(), app));
|
||||||
lyrics_providers->AddProvider(new GeniusLyricsProvider(app));
|
lyrics_providers->AddProvider(new GeniusLyricsProvider(lyrics_providers->network(), app));
|
||||||
lyrics_providers->AddProvider(new OVHLyricsProvider(app));
|
lyrics_providers->AddProvider(new OVHLyricsProvider(lyrics_providers->network(), app));
|
||||||
lyrics_providers->AddProvider(new LoloLyricsProvider(app));
|
lyrics_providers->AddProvider(new LoloLyricsProvider(lyrics_providers->network(), app));
|
||||||
lyrics_providers->AddProvider(new MusixmatchLyricsProvider(app));
|
lyrics_providers->AddProvider(new MusixmatchLyricsProvider(lyrics_providers->network(), app));
|
||||||
lyrics_providers->AddProvider(new ChartLyricsProvider(app));
|
lyrics_providers->AddProvider(new ChartLyricsProvider(lyrics_providers->network(), app));
|
||||||
lyrics_providers->ReloadSettings();
|
lyrics_providers->ReloadSettings();
|
||||||
return lyrics_providers;
|
return lyrics_providers;
|
||||||
}),
|
}),
|
||||||
|
@ -27,4 +27,4 @@
|
|||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "coverprovider.h"
|
#include "coverprovider.h"
|
||||||
|
|
||||||
CoverProvider::CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, QObject *parent) : QObject(parent), app_(app), name_(name), enabled_(enabled), order_(0), authentication_required_(authentication_required), quality_(quality), batch_(batch), allow_missing_album_(allow_missing_album) {}
|
CoverProvider::CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, NetworkAccessManager *network, QObject *parent) : QObject(parent), app_(app), network_(network), name_(name), enabled_(enabled), order_(0), authentication_required_(authentication_required), quality_(quality), batch_(batch), allow_missing_album_(allow_missing_album) {}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "albumcoverfetcher.h"
|
#include "albumcoverfetcher.h"
|
||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
|
class NetworkAccessManager;
|
||||||
|
|
||||||
// Each implementation of this interface downloads covers from one online service.
|
// Each implementation of this interface downloads covers from one online service.
|
||||||
// There are no limitations on what this service might be - last.fm, Amazon, Google Images - you name it.
|
// There are no limitations on what this service might be - last.fm, Amazon, Google Images - you name it.
|
||||||
@ -40,7 +41,7 @@ class CoverProvider : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, QObject *parent);
|
explicit CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, NetworkAccessManager *network, QObject *parent);
|
||||||
|
|
||||||
// A name (very short description) of this provider, like "last.fm".
|
// A name (very short description) of this provider, like "last.fm".
|
||||||
QString name() const { return name_; }
|
QString name() const { return name_; }
|
||||||
@ -73,8 +74,9 @@ class CoverProvider : public QObject {
|
|||||||
void SearchResults(int, CoverProviderSearchResults);
|
void SearchResults(int, CoverProviderSearchResults);
|
||||||
void SearchFinished(int, CoverProviderSearchResults);
|
void SearchFinished(int, CoverProviderSearchResults);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
Application *app_;
|
Application *app_;
|
||||||
|
NetworkAccessManager *network_;
|
||||||
QString name_;
|
QString name_;
|
||||||
bool enabled_;
|
bool enabled_;
|
||||||
int order_;
|
int order_;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
#include "core/networkaccessmanager.h"
|
||||||
#include "coverprovider.h"
|
#include "coverprovider.h"
|
||||||
#include "coverproviders.h"
|
#include "coverproviders.h"
|
||||||
|
|
||||||
@ -40,7 +41,7 @@
|
|||||||
|
|
||||||
int CoverProviders::NextOrderId = 0;
|
int CoverProviders::NextOrderId = 0;
|
||||||
|
|
||||||
CoverProviders::CoverProviders(QObject *parent) : QObject(parent) {}
|
CoverProviders::CoverProviders(QObject *parent) : QObject(parent), network_(new NetworkAccessManager(this)) {}
|
||||||
|
|
||||||
CoverProviders::~CoverProviders() {
|
CoverProviders::~CoverProviders() {
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QAtomicInt>
|
#include <QAtomicInt>
|
||||||
|
|
||||||
|
class NetworkAccessManager;
|
||||||
class CoverProvider;
|
class CoverProvider;
|
||||||
|
|
||||||
// This is a repository for cover providers.
|
// This is a repository for cover providers.
|
||||||
@ -59,6 +60,8 @@ class CoverProviders : public QObject {
|
|||||||
|
|
||||||
int NextId();
|
int NextId();
|
||||||
|
|
||||||
|
NetworkAccessManager *network() const { return network_; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ProviderDestroyed();
|
void ProviderDestroyed();
|
||||||
|
|
||||||
@ -67,6 +70,8 @@ class CoverProviders : public QObject {
|
|||||||
|
|
||||||
static int NextOrderId;
|
static int NextOrderId;
|
||||||
|
|
||||||
|
NetworkAccessManager *network_;
|
||||||
|
|
||||||
QMap<CoverProvider*, QString> cover_providers_;
|
QMap<CoverProvider*, QString> cover_providers_;
|
||||||
QMutex mutex_;
|
QMutex mutex_;
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -53,9 +52,8 @@
|
|||||||
const char *DeezerCoverProvider::kApiUrl = "https://api.deezer.com";
|
const char *DeezerCoverProvider::kApiUrl = "https://api.deezer.com";
|
||||||
const int DeezerCoverProvider::kLimit = 10;
|
const int DeezerCoverProvider::kLimit = 10;
|
||||||
|
|
||||||
DeezerCoverProvider::DeezerCoverProvider(Application *app, QObject *parent)
|
DeezerCoverProvider::DeezerCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||||
: JsonCoverProvider("Deezer", true, false, 2.0, true, true, app, parent),
|
: JsonCoverProvider("Deezer", true, false, 2.0, true, true, app, network, parent) {}
|
||||||
network_(new NetworkAccessManager(this)) {}
|
|
||||||
|
|
||||||
DeezerCoverProvider::~DeezerCoverProvider() {
|
DeezerCoverProvider::~DeezerCoverProvider() {
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class DeezerCoverProvider : public JsonCoverProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeezerCoverProvider(Application *app, QObject *parent = nullptr);
|
explicit DeezerCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~DeezerCoverProvider() override;
|
~DeezerCoverProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||||
@ -58,7 +58,6 @@ class DeezerCoverProvider : public JsonCoverProvider {
|
|||||||
static const char *kApiUrl;
|
static const char *kApiUrl;
|
||||||
static const int kLimit;
|
static const int kLimit;
|
||||||
|
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -61,9 +60,8 @@ const char *DiscogsCoverProvider::kAccessKeyB64 = "dGh6ZnljUGJlZ1NEeXBuSFFxSVk="
|
|||||||
const char *DiscogsCoverProvider::kSecretKeyB64 = "ZkFIcmlaSER4aHhRSlF2U3d0bm5ZVmdxeXFLWUl0UXI=";
|
const char *DiscogsCoverProvider::kSecretKeyB64 = "ZkFIcmlaSER4aHhRSlF2U3d0bm5ZVmdxeXFLWUl0UXI=";
|
||||||
const int DiscogsCoverProvider::kRequestsDelay = 1000;
|
const int DiscogsCoverProvider::kRequestsDelay = 1000;
|
||||||
|
|
||||||
DiscogsCoverProvider::DiscogsCoverProvider(Application *app, QObject *parent)
|
DiscogsCoverProvider::DiscogsCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||||
: JsonCoverProvider("Discogs", false, false, 0.0, false, false, app, parent),
|
: JsonCoverProvider("Discogs", false, false, 0.0, false, false, app, network, parent),
|
||||||
network_(new NetworkAccessManager(this)),
|
|
||||||
timer_flush_requests_(new QTimer(this)) {
|
timer_flush_requests_(new QTimer(this)) {
|
||||||
|
|
||||||
timer_flush_requests_->setInterval(kRequestsDelay);
|
timer_flush_requests_->setInterval(kRequestsDelay);
|
||||||
|
@ -49,7 +49,7 @@ class DiscogsCoverProvider : public JsonCoverProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DiscogsCoverProvider(Application *app, QObject *parent = nullptr);
|
explicit DiscogsCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~DiscogsCoverProvider() override;
|
~DiscogsCoverProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||||
@ -99,7 +99,6 @@ class DiscogsCoverProvider : public JsonCoverProvider {
|
|||||||
static const char *kSecretKeyB64;
|
static const char *kSecretKeyB64;
|
||||||
static const int kRequestsDelay;
|
static const int kRequestsDelay;
|
||||||
|
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QTimer *timer_flush_requests_;
|
QTimer *timer_flush_requests_;
|
||||||
QQueue<std::shared_ptr<DiscogsCoverSearchContext>> queue_search_requests_;
|
QQueue<std::shared_ptr<DiscogsCoverSearchContext>> queue_search_requests_;
|
||||||
QQueue<DiscogsCoverReleaseContext> queue_release_requests_;
|
QQueue<DiscogsCoverReleaseContext> queue_release_requests_;
|
||||||
|
@ -28,11 +28,12 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
#include "core/networkaccessmanager.h"
|
||||||
#include "coverprovider.h"
|
#include "coverprovider.h"
|
||||||
#include "jsoncoverprovider.h"
|
#include "jsoncoverprovider.h"
|
||||||
|
|
||||||
JsonCoverProvider::JsonCoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, QObject *parent)
|
JsonCoverProvider::JsonCoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, NetworkAccessManager *network, QObject *parent)
|
||||||
: CoverProvider(name, enabled, authentication_required, quality, batch, allow_missing_album, app, parent) {}
|
: CoverProvider(name, enabled, authentication_required, quality, batch, allow_missing_album, app, network, parent) {}
|
||||||
|
|
||||||
QJsonObject JsonCoverProvider::ExtractJsonObj(const QByteArray &data) {
|
QJsonObject JsonCoverProvider::ExtractJsonObj(const QByteArray &data) {
|
||||||
|
|
||||||
|
@ -30,15 +30,16 @@
|
|||||||
#include "coverprovider.h"
|
#include "coverprovider.h"
|
||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
|
class NetworkAccessManager;
|
||||||
|
|
||||||
class JsonCoverProvider : public CoverProvider {
|
class JsonCoverProvider : public CoverProvider {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit JsonCoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, QObject *parent);
|
explicit JsonCoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, NetworkAccessManager *network, QObject *parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
QJsonObject ExtractJsonObj(const QByteArray &data);
|
QJsonObject ExtractJsonObj(const QByteArray &data);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // JSONCOVERPROVIDER_H
|
#endif // JSONCOVERPROVIDER_H
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
@ -53,9 +52,8 @@ const char *LastFmCoverProvider::kUrl = "https://ws.audioscrobbler.com/2.0/";
|
|||||||
const char *LastFmCoverProvider::kApiKey = "211990b4c96782c05d1536e7219eb56e";
|
const char *LastFmCoverProvider::kApiKey = "211990b4c96782c05d1536e7219eb56e";
|
||||||
const char *LastFmCoverProvider::kSecret = "80fd738f49596e9709b1bf9319c444a8";
|
const char *LastFmCoverProvider::kSecret = "80fd738f49596e9709b1bf9319c444a8";
|
||||||
|
|
||||||
LastFmCoverProvider::LastFmCoverProvider(Application *app, QObject *parent)
|
LastFmCoverProvider::LastFmCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||||
: JsonCoverProvider("Last.fm", true, false, 1.0, true, false, app, parent),
|
: JsonCoverProvider("Last.fm", true, false, 1.0, true, false, app, network, parent) {}
|
||||||
network_(new NetworkAccessManager(this)) {}
|
|
||||||
|
|
||||||
LastFmCoverProvider::~LastFmCoverProvider() {
|
LastFmCoverProvider::~LastFmCoverProvider() {
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class LastFmCoverProvider : public JsonCoverProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LastFmCoverProvider(Application *app, QObject *parent = nullptr);
|
explicit LastFmCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~LastFmCoverProvider() override;
|
~LastFmCoverProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||||
@ -65,7 +65,6 @@ class LastFmCoverProvider : public JsonCoverProvider {
|
|||||||
static const char *kApiKey;
|
static const char *kApiKey;
|
||||||
static const char *kSecret;
|
static const char *kSecret;
|
||||||
|
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -51,9 +50,8 @@ const char *MusicbrainzCoverProvider::kAlbumCoverUrl = "https://coverartarchive.
|
|||||||
const int MusicbrainzCoverProvider::kLimit = 8;
|
const int MusicbrainzCoverProvider::kLimit = 8;
|
||||||
const int MusicbrainzCoverProvider::kRequestsDelay = 1000;
|
const int MusicbrainzCoverProvider::kRequestsDelay = 1000;
|
||||||
|
|
||||||
MusicbrainzCoverProvider::MusicbrainzCoverProvider(Application *app, QObject *parent)
|
MusicbrainzCoverProvider::MusicbrainzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||||
: JsonCoverProvider("MusicBrainz", true, false, 1.5, true, false, app, parent),
|
: JsonCoverProvider("MusicBrainz", true, false, 1.5, true, false, app, network, parent),
|
||||||
network_(new NetworkAccessManager(this)),
|
|
||||||
timer_flush_requests_(new QTimer(this)) {
|
timer_flush_requests_(new QTimer(this)) {
|
||||||
|
|
||||||
timer_flush_requests_->setInterval(kRequestsDelay);
|
timer_flush_requests_->setInterval(kRequestsDelay);
|
||||||
|
@ -41,7 +41,7 @@ class MusicbrainzCoverProvider : public JsonCoverProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MusicbrainzCoverProvider(Application *app, QObject *parent = nullptr);
|
explicit MusicbrainzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~MusicbrainzCoverProvider() override;
|
~MusicbrainzCoverProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||||
@ -68,7 +68,6 @@ class MusicbrainzCoverProvider : public JsonCoverProvider {
|
|||||||
static const int kLimit;
|
static const int kLimit;
|
||||||
static const int kRequestsDelay;
|
static const int kRequestsDelay;
|
||||||
|
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QTimer *timer_flush_requests_;
|
QTimer *timer_flush_requests_;
|
||||||
QQueue<SearchRequest> queue_search_requests_;
|
QQueue<SearchRequest> queue_search_requests_;
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -40,9 +39,8 @@
|
|||||||
#include "jsoncoverprovider.h"
|
#include "jsoncoverprovider.h"
|
||||||
#include "musixmatchcoverprovider.h"
|
#include "musixmatchcoverprovider.h"
|
||||||
|
|
||||||
MusixmatchCoverProvider::MusixmatchCoverProvider(Application *app, QObject *parent)
|
MusixmatchCoverProvider::MusixmatchCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||||
: JsonCoverProvider("Musixmatch", true, false, 1.0, true, false, app, parent),
|
: JsonCoverProvider("Musixmatch", true, false, 1.0, true, false, app, network, parent) {}
|
||||||
network_(new NetworkAccessManager(this)) {}
|
|
||||||
|
|
||||||
MusixmatchCoverProvider::~MusixmatchCoverProvider() {
|
MusixmatchCoverProvider::~MusixmatchCoverProvider() {
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class MusixmatchCoverProvider : public JsonCoverProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MusixmatchCoverProvider(Application *app, QObject *parent = nullptr);
|
explicit MusixmatchCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~MusixmatchCoverProvider() override;
|
~MusixmatchCoverProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||||
@ -50,7 +50,6 @@ class MusixmatchCoverProvider : public JsonCoverProvider {
|
|||||||
void HandleSearchReply(QNetworkReply *reply, const int id, const QString &artist, const QString &album);
|
void HandleSearchReply(QNetworkReply *reply, const int id, const QString &artist, const QString &album);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -52,10 +51,9 @@
|
|||||||
|
|
||||||
const int QobuzCoverProvider::kLimit = 10;
|
const int QobuzCoverProvider::kLimit = 10;
|
||||||
|
|
||||||
QobuzCoverProvider::QobuzCoverProvider(Application *app, QObject *parent)
|
QobuzCoverProvider::QobuzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||||
: JsonCoverProvider("Qobuz", true, true, 2.0, true, true, app, parent),
|
: JsonCoverProvider("Qobuz", true, true, 2.0, true, true, app, network, parent),
|
||||||
service_(app->internet_services()->Service<QobuzService>()),
|
service_(app->internet_services()->Service<QobuzService>()) {}
|
||||||
network_(new NetworkAccessManager(this)) {}
|
|
||||||
|
|
||||||
QobuzCoverProvider::~QobuzCoverProvider() {
|
QobuzCoverProvider::~QobuzCoverProvider() {
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class QobuzCoverProvider : public JsonCoverProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QobuzCoverProvider(Application *app, QObject *parent = nullptr);
|
explicit QobuzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~QobuzCoverProvider() override;
|
~QobuzCoverProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||||
@ -65,7 +65,6 @@ class QobuzCoverProvider : public JsonCoverProvider {
|
|||||||
static const int kLimit;
|
static const int kLimit;
|
||||||
|
|
||||||
QobuzService *service_;
|
QobuzService *service_;
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QSslError>
|
#include <QSslError>
|
||||||
@ -63,9 +62,8 @@ const char *SpotifyCoverProvider::kClientSecretB64 = "N2ZlMDMxODk1NTBlNDE3ZGI1ZW
|
|||||||
const char *SpotifyCoverProvider::kApiUrl = "https://api.spotify.com/v1";
|
const char *SpotifyCoverProvider::kApiUrl = "https://api.spotify.com/v1";
|
||||||
const int SpotifyCoverProvider::kLimit = 10;
|
const int SpotifyCoverProvider::kLimit = 10;
|
||||||
|
|
||||||
SpotifyCoverProvider::SpotifyCoverProvider(Application *app, QObject *parent)
|
SpotifyCoverProvider::SpotifyCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||||
: JsonCoverProvider("Spotify", true, true, 2.5, true, true, app, parent),
|
: JsonCoverProvider("Spotify", true, true, 2.5, true, true, app, network, parent),
|
||||||
network_(new NetworkAccessManager(this)),
|
|
||||||
server_(nullptr),
|
server_(nullptr),
|
||||||
expires_in_(0),
|
expires_in_(0),
|
||||||
login_time_(0) {
|
login_time_(0) {
|
||||||
|
@ -45,7 +45,7 @@ class SpotifyCoverProvider : public JsonCoverProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SpotifyCoverProvider(Application *app, QObject *parent = nullptr);
|
explicit SpotifyCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~SpotifyCoverProvider() override;
|
~SpotifyCoverProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||||
@ -81,7 +81,6 @@ class SpotifyCoverProvider : public JsonCoverProvider {
|
|||||||
static const char *kApiUrl;
|
static const char *kApiUrl;
|
||||||
static const int kLimit;
|
static const int kLimit;
|
||||||
|
|
||||||
NetworkAccessManager *network_;
|
|
||||||
LocalRedirectServer *server_;
|
LocalRedirectServer *server_;
|
||||||
QStringList login_errors_;
|
QStringList login_errors_;
|
||||||
QString code_verifier_;
|
QString code_verifier_;
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -50,10 +49,9 @@
|
|||||||
|
|
||||||
const int TidalCoverProvider::kLimit = 10;
|
const int TidalCoverProvider::kLimit = 10;
|
||||||
|
|
||||||
TidalCoverProvider::TidalCoverProvider(Application *app, QObject *parent)
|
TidalCoverProvider::TidalCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||||
: JsonCoverProvider("Tidal", true, true, 2.5, true, true, app, parent),
|
: JsonCoverProvider("Tidal", true, true, 2.5, true, true, app, network, parent),
|
||||||
service_(app->internet_services()->Service<TidalService>()),
|
service_(app->internet_services()->Service<TidalService>()) {}
|
||||||
network_(new NetworkAccessManager(this)) {}
|
|
||||||
|
|
||||||
TidalCoverProvider::~TidalCoverProvider() {
|
TidalCoverProvider::~TidalCoverProvider() {
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class TidalCoverProvider : public JsonCoverProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TidalCoverProvider(Application *app, QObject *parent = nullptr);
|
explicit TidalCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~TidalCoverProvider() override;
|
~TidalCoverProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||||
@ -63,7 +63,6 @@ class TidalCoverProvider : public JsonCoverProvider {
|
|||||||
static const int kLimit;
|
static const int kLimit;
|
||||||
|
|
||||||
TidalService *service_;
|
TidalService *service_;
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
@ -47,7 +46,7 @@ const char *AuddLyricsProvider::kUrlSearch = "https://api.audd.io/findLyrics/";
|
|||||||
const char *AuddLyricsProvider::kAPITokenB64 = "ZjA0NjQ4YjgyNDM3ZTc1MjY3YjJlZDI5ZDBlMzQxZjk=";
|
const char *AuddLyricsProvider::kAPITokenB64 = "ZjA0NjQ4YjgyNDM3ZTc1MjY3YjJlZDI5ZDBlMzQxZjk=";
|
||||||
const int AuddLyricsProvider::kMaxLength = 6000;
|
const int AuddLyricsProvider::kMaxLength = 6000;
|
||||||
|
|
||||||
AuddLyricsProvider::AuddLyricsProvider(QObject *parent) : JsonLyricsProvider("AudD", true, false, parent), network_(new NetworkAccessManager(this)) {}
|
AuddLyricsProvider::AuddLyricsProvider(NetworkAccessManager *network, QObject *parent) : JsonLyricsProvider("AudD", true, false, network, parent) {}
|
||||||
|
|
||||||
AuddLyricsProvider::~AuddLyricsProvider() {
|
AuddLyricsProvider::~AuddLyricsProvider() {
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class AuddLyricsProvider : public JsonLyricsProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AuddLyricsProvider(QObject *parent = nullptr);
|
explicit AuddLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~AuddLyricsProvider() override;
|
~AuddLyricsProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, quint64 id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, quint64 id) override;
|
||||||
@ -56,7 +56,6 @@ class AuddLyricsProvider : public JsonLyricsProvider {
|
|||||||
static const char *kUrlSearch;
|
static const char *kUrlSearch;
|
||||||
static const char *kAPITokenB64;
|
static const char *kAPITokenB64;
|
||||||
static const int kMaxLength;
|
static const int kMaxLength;
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
@ -41,7 +40,7 @@
|
|||||||
|
|
||||||
const char *ChartLyricsProvider::kUrlSearch = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect";
|
const char *ChartLyricsProvider::kUrlSearch = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect";
|
||||||
|
|
||||||
ChartLyricsProvider::ChartLyricsProvider(QObject *parent) : LyricsProvider("ChartLyrics", false, false, parent), network_(new NetworkAccessManager(this)) {}
|
ChartLyricsProvider::ChartLyricsProvider(NetworkAccessManager *network, QObject *parent) : LyricsProvider("ChartLyrics", false, false, network, parent) {}
|
||||||
|
|
||||||
ChartLyricsProvider::~ChartLyricsProvider() {
|
ChartLyricsProvider::~ChartLyricsProvider() {
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class ChartLyricsProvider : public LyricsProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ChartLyricsProvider(QObject *parent = nullptr);
|
explicit ChartLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~ChartLyricsProvider() override;
|
~ChartLyricsProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id) override;
|
||||||
@ -51,8 +51,6 @@ class ChartLyricsProvider : public LyricsProvider {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static const char *kUrlSearch;
|
static const char *kUrlSearch;
|
||||||
|
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QSslError>
|
#include <QSslError>
|
||||||
@ -62,7 +61,7 @@ const char *GeniusLyricsProvider::kUrlSearch = "https://api.genius.com/search/";
|
|||||||
const char *GeniusLyricsProvider::kClientIDB64 = "RUNTNXU4U1VyMU1KUU5hdTZySEZteUxXY2hkanFiY3lfc2JjdXBpNG5WMU9SNUg4dTBZelEtZTZCdFg2dl91SQ==";
|
const char *GeniusLyricsProvider::kClientIDB64 = "RUNTNXU4U1VyMU1KUU5hdTZySEZteUxXY2hkanFiY3lfc2JjdXBpNG5WMU9SNUg4dTBZelEtZTZCdFg2dl91SQ==";
|
||||||
const char *GeniusLyricsProvider::kClientSecretB64 = "VE9pMU9vUjNtTXZ3eFR3YVN0QVRyUjVoUlhVWDI1Ylp5X240eEt1M0ZkYlNwRG5JUnd0LXFFbHdGZkZkRWY2VzJ1S011UnQzM3c2Y3hqY0tVZ3NGN2c=";
|
const char *GeniusLyricsProvider::kClientSecretB64 = "VE9pMU9vUjNtTXZ3eFR3YVN0QVRyUjVoUlhVWDI1Ylp5X240eEt1M0ZkYlNwRG5JUnd0LXFFbHdGZkZkRWY2VzJ1S011UnQzM3c2Y3hqY0tVZ3NGN2c=";
|
||||||
|
|
||||||
GeniusLyricsProvider::GeniusLyricsProvider(QObject *parent) : JsonLyricsProvider("Genius", true, true, parent), network_(new NetworkAccessManager(this)), server_(nullptr) {
|
GeniusLyricsProvider::GeniusLyricsProvider(NetworkAccessManager *network, QObject *parent) : JsonLyricsProvider("Genius", true, true, network, parent), server_(nullptr) {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
|
@ -46,7 +46,7 @@ class GeniusLyricsProvider : public JsonLyricsProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GeniusLyricsProvider(QObject *parent = nullptr);
|
explicit GeniusLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~GeniusLyricsProvider() override;
|
~GeniusLyricsProvider() override;
|
||||||
|
|
||||||
bool IsAuthenticated() const override { return !access_token_.isEmpty(); }
|
bool IsAuthenticated() const override { return !access_token_.isEmpty(); }
|
||||||
@ -95,7 +95,6 @@ class GeniusLyricsProvider : public JsonLyricsProvider {
|
|||||||
static const char *kUrlSearch;
|
static const char *kUrlSearch;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NetworkAccessManager *network_;
|
|
||||||
LocalRedirectServer *server_;
|
LocalRedirectServer *server_;
|
||||||
QString code_verifier_;
|
QString code_verifier_;
|
||||||
QString code_challenge_;
|
QString code_challenge_;
|
||||||
|
@ -27,10 +27,11 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#include "core/networkaccessmanager.h"
|
||||||
#include "lyricsprovider.h"
|
#include "lyricsprovider.h"
|
||||||
#include "jsonlyricsprovider.h"
|
#include "jsonlyricsprovider.h"
|
||||||
|
|
||||||
JsonLyricsProvider::JsonLyricsProvider(const QString &name, const bool enabled, const bool authentication_required, QObject *parent) : LyricsProvider(name, enabled, authentication_required, parent) {}
|
JsonLyricsProvider::JsonLyricsProvider(const QString &name, const bool enabled, const bool authentication_required, NetworkAccessManager *network, QObject *parent) : LyricsProvider(name, enabled, authentication_required, network, parent) {}
|
||||||
|
|
||||||
QByteArray JsonLyricsProvider::ExtractData(QNetworkReply *reply) {
|
QByteArray JsonLyricsProvider::ExtractData(QNetworkReply *reply) {
|
||||||
|
|
||||||
|
@ -31,14 +31,16 @@
|
|||||||
|
|
||||||
#include "lyricsprovider.h"
|
#include "lyricsprovider.h"
|
||||||
|
|
||||||
|
class NetworkAccessManager;
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
|
||||||
class JsonLyricsProvider : public LyricsProvider {
|
class JsonLyricsProvider : public LyricsProvider {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit JsonLyricsProvider(const QString &name, const bool enabled = true, const bool authentication_required = false, QObject *parent = nullptr);
|
explicit JsonLyricsProvider(const QString &name, const bool enabled, const bool authentication_required, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
QByteArray ExtractData(QNetworkReply *reply);
|
QByteArray ExtractData(QNetworkReply *reply);
|
||||||
QJsonObject ExtractJsonObj(const QByteArray &data);
|
QJsonObject ExtractJsonObj(const QByteArray &data);
|
||||||
QJsonObject ExtractJsonObj(QNetworkReply *reply);
|
QJsonObject ExtractJsonObj(QNetworkReply *reply);
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
@ -42,7 +41,7 @@
|
|||||||
|
|
||||||
const char *LoloLyricsProvider::kUrlSearch = "http://api.lololyrics.com/0.5/getLyric";
|
const char *LoloLyricsProvider::kUrlSearch = "http://api.lololyrics.com/0.5/getLyric";
|
||||||
|
|
||||||
LoloLyricsProvider::LoloLyricsProvider(QObject *parent) : LyricsProvider("LoloLyrics", true, false, parent), network_(new NetworkAccessManager(this)) {}
|
LoloLyricsProvider::LoloLyricsProvider(NetworkAccessManager *network, QObject *parent) : LyricsProvider("LoloLyrics", true, false, network, parent) {}
|
||||||
|
|
||||||
LoloLyricsProvider::~LoloLyricsProvider() {
|
LoloLyricsProvider::~LoloLyricsProvider() {
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class LoloLyricsProvider : public LyricsProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LoloLyricsProvider(QObject *parent = nullptr);
|
explicit LoloLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~LoloLyricsProvider() override;
|
~LoloLyricsProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id) override;
|
||||||
@ -51,7 +51,6 @@ class LoloLyricsProvider : public LyricsProvider {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static const char *kUrlSearch;
|
static const char *kUrlSearch;
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include "core/networkaccessmanager.h"
|
||||||
#include "lyricsprovider.h"
|
#include "lyricsprovider.h"
|
||||||
|
|
||||||
LyricsProvider::LyricsProvider(const QString &name, const bool enabled, const bool authentication_required, QObject *parent)
|
LyricsProvider::LyricsProvider(const QString &name, const bool enabled, const bool authentication_required, NetworkAccessManager *network, QObject *parent)
|
||||||
: QObject(parent), name_(name), enabled_(enabled), order_(0), authentication_required_(authentication_required) {}
|
: QObject(parent), network_(network), name_(name), enabled_(enabled), order_(0), authentication_required_(authentication_required) {}
|
||||||
|
@ -31,11 +31,13 @@
|
|||||||
|
|
||||||
#include "lyricsfetcher.h"
|
#include "lyricsfetcher.h"
|
||||||
|
|
||||||
|
class NetworkAccessManager;
|
||||||
|
|
||||||
class LyricsProvider : public QObject {
|
class LyricsProvider : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LyricsProvider(const QString &name, const bool enabled, const bool authentication_required, QObject *parent);
|
explicit LyricsProvider(const QString &name, const bool enabled, const bool authentication_required, NetworkAccessManager *network, QObject *parent);
|
||||||
|
|
||||||
typedef QPair<QString, QString> Param;
|
typedef QPair<QString, QString> Param;
|
||||||
typedef QList<Param> ParamList;
|
typedef QList<Param> ParamList;
|
||||||
@ -62,7 +64,8 @@ class LyricsProvider : public QObject {
|
|||||||
void AuthenticationFailure(QStringList);
|
void AuthenticationFailure(QStringList);
|
||||||
void SearchFinished(quint64 id, LyricsSearchResults results);
|
void SearchFinished(quint64 id, LyricsSearchResults results);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
NetworkAccessManager *network_;
|
||||||
QString name_;
|
QString name_;
|
||||||
bool enabled_;
|
bool enabled_;
|
||||||
int order_;
|
int order_;
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
#include "core/networkaccessmanager.h"
|
||||||
|
|
||||||
#include "lyricsprovider.h"
|
#include "lyricsprovider.h"
|
||||||
#include "lyricsproviders.h"
|
#include "lyricsproviders.h"
|
||||||
|
|
||||||
@ -38,7 +40,7 @@
|
|||||||
|
|
||||||
int LyricsProviders::NextOrderId = 0;
|
int LyricsProviders::NextOrderId = 0;
|
||||||
|
|
||||||
LyricsProviders::LyricsProviders(QObject *parent) : QObject(parent) {}
|
LyricsProviders::LyricsProviders(QObject *parent) : QObject(parent), network_(new NetworkAccessManager(this)) {}
|
||||||
|
|
||||||
LyricsProviders::~LyricsProviders() {
|
LyricsProviders::~LyricsProviders() {
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QAtomicInt>
|
#include <QAtomicInt>
|
||||||
|
|
||||||
|
class NetworkAccessManager;
|
||||||
class LyricsProvider;
|
class LyricsProvider;
|
||||||
|
|
||||||
class LyricsProviders : public QObject {
|
class LyricsProviders : public QObject {
|
||||||
@ -48,6 +49,8 @@ class LyricsProviders : public QObject {
|
|||||||
bool HasAnyProviders() const { return !lyrics_providers_.isEmpty(); }
|
bool HasAnyProviders() const { return !lyrics_providers_.isEmpty(); }
|
||||||
int NextId();
|
int NextId();
|
||||||
|
|
||||||
|
NetworkAccessManager *network() const { return network_; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ProviderDestroyed();
|
void ProviderDestroyed();
|
||||||
|
|
||||||
@ -56,6 +59,8 @@ class LyricsProviders : public QObject {
|
|||||||
|
|
||||||
static int NextOrderId;
|
static int NextOrderId;
|
||||||
|
|
||||||
|
NetworkAccessManager *network_;
|
||||||
|
|
||||||
QMap<LyricsProvider*, QString> lyrics_providers_;
|
QMap<LyricsProvider*, QString> lyrics_providers_;
|
||||||
QList<LyricsProvider*> ordered_providers_;
|
QList<LyricsProvider*> ordered_providers_;
|
||||||
QMutex mutex_;
|
QMutex mutex_;
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
@ -40,7 +39,7 @@
|
|||||||
#include "lyricsprovider.h"
|
#include "lyricsprovider.h"
|
||||||
#include "musixmatchlyricsprovider.h"
|
#include "musixmatchlyricsprovider.h"
|
||||||
|
|
||||||
MusixmatchLyricsProvider::MusixmatchLyricsProvider(QObject *parent) : JsonLyricsProvider("Musixmatch", true, false, parent), network_(new NetworkAccessManager(this)) {}
|
MusixmatchLyricsProvider::MusixmatchLyricsProvider(NetworkAccessManager *network, QObject *parent) : JsonLyricsProvider("Musixmatch", true, false, network, parent) {}
|
||||||
|
|
||||||
MusixmatchLyricsProvider::~MusixmatchLyricsProvider() {
|
MusixmatchLyricsProvider::~MusixmatchLyricsProvider() {
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class MusixmatchLyricsProvider : public JsonLyricsProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MusixmatchLyricsProvider(QObject *parent = nullptr);
|
explicit MusixmatchLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~MusixmatchLyricsProvider() override;
|
~MusixmatchLyricsProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id) override;
|
||||||
@ -51,7 +51,6 @@ class MusixmatchLyricsProvider : public JsonLyricsProvider {
|
|||||||
void HandleSearchReply(QNetworkReply *reply, const quint64 id, const QString &artist, const QString &album, const QString &title);
|
void HandleSearchReply(QNetworkReply *reply, const quint64 id, const QString &artist, const QString &album, const QString &title);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
@ -39,7 +38,7 @@
|
|||||||
|
|
||||||
const char *OVHLyricsProvider::kUrlSearch = "https://api.lyrics.ovh/v1/";
|
const char *OVHLyricsProvider::kUrlSearch = "https://api.lyrics.ovh/v1/";
|
||||||
|
|
||||||
OVHLyricsProvider::OVHLyricsProvider(QObject *parent) : JsonLyricsProvider("Lyrics.ovh", true, false, parent), network_(new NetworkAccessManager(this)) {}
|
OVHLyricsProvider::OVHLyricsProvider(NetworkAccessManager *network, QObject *parent) : JsonLyricsProvider("Lyrics.ovh", true, false, network, parent) {}
|
||||||
|
|
||||||
OVHLyricsProvider::~OVHLyricsProvider() {
|
OVHLyricsProvider::~OVHLyricsProvider() {
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class OVHLyricsProvider : public JsonLyricsProvider {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OVHLyricsProvider(QObject *parent = nullptr);
|
explicit OVHLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||||
~OVHLyricsProvider() override;
|
~OVHLyricsProvider() override;
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id) override;
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id) override;
|
||||||
@ -51,7 +51,6 @@ class OVHLyricsProvider : public JsonLyricsProvider {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static const char *kUrlSearch;
|
static const char *kUrlSearch;
|
||||||
NetworkAccessManager *network_;
|
|
||||||
QList<QNetworkReply*> replies_;
|
QList<QNetworkReply*> replies_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user