@@ -30,6 +30,7 @@
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/strutils.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
@@ -38,7 +39,7 @@
|
||||
|
||||
const char *ChartLyricsProvider::kUrlSearch = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect";
|
||||
|
||||
ChartLyricsProvider::ChartLyricsProvider(NetworkAccessManager *network, QObject *parent) : LyricsProvider("ChartLyrics", false, false, network, parent) {}
|
||||
ChartLyricsProvider::ChartLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : LyricsProvider("ChartLyrics", false, false, network, parent) {}
|
||||
|
||||
ChartLyricsProvider::~ChartLyricsProvider() {
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "lyricsprovider.h"
|
||||
#include "lyricsfetcher.h"
|
||||
|
||||
@@ -37,7 +38,7 @@ class ChartLyricsProvider : public LyricsProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChartLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit ChartLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~ChartLyricsProvider() override;
|
||||
|
||||
bool StartSearch(const int id, const LyricsSearchRequest &request) override;
|
||||
|
||||
@@ -43,12 +43,15 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/randutils.h"
|
||||
#include "internet/localredirectserver.h"
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "geniuslyricsprovider.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
const char *GeniusLyricsProvider::kSettingsGroup = "GeniusLyrics";
|
||||
const char *GeniusLyricsProvider::kOAuthAuthorizeUrl = "https://api.genius.com/oauth/authorize";
|
||||
const char *GeniusLyricsProvider::kOAuthAccessTokenUrl = "https://api.genius.com/oauth/token";
|
||||
@@ -57,7 +60,7 @@ const char *GeniusLyricsProvider::kUrlSearch = "https://api.genius.com/search/";
|
||||
const char *GeniusLyricsProvider::kClientIDB64 = "RUNTNXU4U1VyMU1KUU5hdTZySEZteUxXY2hkanFiY3lfc2JjdXBpNG5WMU9SNUg4dTBZelEtZTZCdFg2dl91SQ==";
|
||||
const char *GeniusLyricsProvider::kClientSecretB64 = "VE9pMU9vUjNtTXZ3eFR3YVN0QVRyUjVoUlhVWDI1Ylp5X240eEt1M0ZkYlNwRG5JUnd0LXFFbHdGZkZkRWY2VzJ1S011UnQzM3c2Y3hqY0tVZ3NGN2c=";
|
||||
|
||||
GeniusLyricsProvider::GeniusLyricsProvider(NetworkAccessManager *network, QObject *parent) : JsonLyricsProvider("Genius", true, true, network, parent), server_(nullptr) {
|
||||
GeniusLyricsProvider::GeniusLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider("Genius", true, true, network, parent), server_(nullptr) {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
@@ -287,7 +290,7 @@ bool GeniusLyricsProvider::StartSearch(const int id, const LyricsSearchRequest &
|
||||
|
||||
if (access_token_.isEmpty()) return false;
|
||||
|
||||
GeniusLyricsSearchContextPtr search = std::make_shared<GeniusLyricsSearchContext>();
|
||||
GeniusLyricsSearchContextPtr search = make_shared<GeniusLyricsSearchContext>();
|
||||
search->id = id;
|
||||
search->request = request;
|
||||
requests_search_.insert(id, search);
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
@@ -35,6 +33,7 @@
|
||||
#include <QSslError>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "lyricssearchresult.h"
|
||||
@@ -47,7 +46,7 @@ class GeniusLyricsProvider : public JsonLyricsProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GeniusLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit GeniusLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~GeniusLyricsProvider() override;
|
||||
|
||||
bool IsAuthenticated() const override { return !access_token_.isEmpty(); }
|
||||
@@ -72,7 +71,7 @@ class GeniusLyricsProvider : public JsonLyricsProvider {
|
||||
LyricsSearchResults results;
|
||||
};
|
||||
|
||||
using GeniusLyricsSearchContextPtr = std::shared_ptr<GeniusLyricsSearchContext>;
|
||||
using GeniusLyricsSearchContextPtr = SharedPtr<GeniusLyricsSearchContext>;
|
||||
|
||||
private:
|
||||
void RequestAccessToken(const QUrl &url, const QUrl &redirect_url);
|
||||
@@ -102,7 +101,7 @@ class GeniusLyricsProvider : public JsonLyricsProvider {
|
||||
QString code_challenge_;
|
||||
QString access_token_;
|
||||
QStringList login_errors_;
|
||||
QMap<int, std::shared_ptr<GeniusLyricsSearchContext>> requests_search_;
|
||||
QMap<int, SharedPtr<GeniusLyricsSearchContext>> requests_search_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,10 +27,11 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "jsonlyricsprovider.h"
|
||||
|
||||
JsonLyricsProvider::JsonLyricsProvider(const QString &name, const bool enabled, const bool authentication_required, NetworkAccessManager *network, QObject *parent) : LyricsProvider(name, enabled, authentication_required, network, parent) {}
|
||||
JsonLyricsProvider::JsonLyricsProvider(const QString &name, const bool enabled, const bool authentication_required, SharedPtr<NetworkAccessManager> network, QObject *parent) : LyricsProvider(name, enabled, authentication_required, network, parent) {}
|
||||
|
||||
QByteArray JsonLyricsProvider::ExtractData(QNetworkReply *reply) {
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "lyricsprovider.h"
|
||||
|
||||
class NetworkAccessManager;
|
||||
@@ -38,7 +39,7 @@ class JsonLyricsProvider : public LyricsProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit JsonLyricsProvider(const QString &name, const bool enabled, const bool authentication_required, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit JsonLyricsProvider(const QString &name, const bool enabled, const bool authentication_required, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
|
||||
protected:
|
||||
QByteArray ExtractData(QNetworkReply *reply);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/strutils.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
@@ -38,7 +39,7 @@
|
||||
|
||||
const char *LoloLyricsProvider::kUrlSearch = "http://api.lololyrics.com/0.5/getLyric";
|
||||
|
||||
LoloLyricsProvider::LoloLyricsProvider(NetworkAccessManager *network, QObject *parent) : LyricsProvider("LoloLyrics", true, false, network, parent) {}
|
||||
LoloLyricsProvider::LoloLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : LyricsProvider("LoloLyrics", true, false, network, parent) {}
|
||||
|
||||
LoloLyricsProvider::~LoloLyricsProvider() {
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "lyricsprovider.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
|
||||
@@ -38,7 +39,7 @@ class LoloLyricsProvider : public LyricsProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LoloLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit LoloLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~LoloLyricsProvider() override;
|
||||
|
||||
bool StartSearch(const int id, const LyricsSearchRequest &request) override;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <QJsonParseError>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "lyricssearchresult.h"
|
||||
@@ -43,7 +44,7 @@ const char *LyricsComLyricsProvider::kLyricsUrl = "https://www.lyrics.com/lyrics
|
||||
const char *LyricsComLyricsProvider::kUID = "11363";
|
||||
const char *LyricsComLyricsProvider::kTokenB64 = "b3FOYmxhV1ZKRGxIMnV4OA==";
|
||||
|
||||
LyricsComLyricsProvider::LyricsComLyricsProvider(NetworkAccessManager *network, QObject *parent) : JsonLyricsProvider("Lyrics.com", true, false, network, parent), use_api_(true) {}
|
||||
LyricsComLyricsProvider::LyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider("Lyrics.com", true, false, network, parent), use_api_(true) {}
|
||||
|
||||
LyricsComLyricsProvider::~LyricsComLyricsProvider() {
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
|
||||
@@ -37,7 +38,7 @@ class LyricsComLyricsProvider : public JsonLyricsProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LyricsComLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit LyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~LyricsComLyricsProvider() override;
|
||||
|
||||
bool StartSearch(const int id, const LyricsSearchRequest &request) override;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <QTimer>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "lyricsfetcher.h"
|
||||
#include "lyricsfetchersearch.h"
|
||||
@@ -36,7 +37,7 @@ using namespace std::chrono_literals;
|
||||
|
||||
const int LyricsFetcher::kMaxConcurrentRequests = 5;
|
||||
|
||||
LyricsFetcher::LyricsFetcher(LyricsProviders *lyrics_providers, QObject *parent)
|
||||
LyricsFetcher::LyricsFetcher(SharedPtr<LyricsProviders> lyrics_providers, QObject *parent)
|
||||
: QObject(parent),
|
||||
lyrics_providers_(lyrics_providers),
|
||||
next_id_(0),
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "lyricssearchresult.h"
|
||||
|
||||
@@ -43,7 +44,7 @@ class LyricsFetcher : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LyricsFetcher(LyricsProviders *lyrics_providers, QObject *parent = nullptr);
|
||||
explicit LyricsFetcher(SharedPtr<LyricsProviders> lyrics_providers, QObject *parent = nullptr);
|
||||
~LyricsFetcher() override {}
|
||||
|
||||
struct Request {
|
||||
@@ -70,7 +71,7 @@ class LyricsFetcher : public QObject {
|
||||
private:
|
||||
static const int kMaxConcurrentRequests;
|
||||
|
||||
LyricsProviders *lyrics_providers_;
|
||||
SharedPtr<LyricsProviders> lyrics_providers_;
|
||||
quint64 next_id_;
|
||||
|
||||
QQueue<Request> queued_requests_;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <QList>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "lyricsfetchersearch.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "lyricssearchresult.h"
|
||||
@@ -56,7 +57,7 @@ void LyricsFetcherSearch::TerminateSearch() {
|
||||
|
||||
}
|
||||
|
||||
void LyricsFetcherSearch::Start(LyricsProviders *lyrics_providers) {
|
||||
void LyricsFetcherSearch::Start(SharedPtr<LyricsProviders> lyrics_providers) {
|
||||
|
||||
// Ignore Radio Paradise "commercial" break.
|
||||
if (request_.artist.compare("commercial-free", Qt::CaseInsensitive) == 0 && request_.title.compare("listener-supported", Qt::CaseInsensitive) == 0) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "lyricssearchresult.h"
|
||||
|
||||
@@ -39,7 +40,7 @@ class LyricsFetcherSearch : public QObject {
|
||||
public:
|
||||
explicit LyricsFetcherSearch(const quint64 id, const LyricsSearchRequest &request, QObject *parent);
|
||||
|
||||
void Start(LyricsProviders *lyrics_providers);
|
||||
void Start(SharedPtr<LyricsProviders> lyrics_providers);
|
||||
void Cancel();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -24,10 +24,11 @@
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "utilities/strutils.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "lyricsprovider.h"
|
||||
|
||||
LyricsProvider::LyricsProvider(const QString &name, const bool enabled, const bool authentication_required, NetworkAccessManager *network, QObject *parent)
|
||||
LyricsProvider::LyricsProvider(const QString &name, const bool enabled, const bool authentication_required, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QObject(parent), network_(network), name_(name), enabled_(enabled), order_(0), authentication_required_(authentication_required) {}
|
||||
|
||||
QString LyricsProvider::ParseLyricsFromHTML(const QString &content, const QRegularExpression &start_tag, const QRegularExpression &end_tag, const QRegularExpression &lyrics_start, const bool multiple) {
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "lyricssearchresult.h"
|
||||
|
||||
@@ -38,7 +39,7 @@ class LyricsProvider : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LyricsProvider(const QString &name, const bool enabled, const bool authentication_required, NetworkAccessManager *network, QObject *parent);
|
||||
explicit LyricsProvider(const QString &name, const bool enabled, const bool authentication_required, SharedPtr<NetworkAccessManager> network, QObject *parent);
|
||||
|
||||
QString name() const { return name_; }
|
||||
bool is_enabled() const { return enabled_; }
|
||||
@@ -66,7 +67,7 @@ class LyricsProvider : public QObject {
|
||||
void SearchFinished(const int id, const LyricsSearchResults &results = LyricsSearchResults());
|
||||
|
||||
protected:
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
QString name_;
|
||||
bool enabled_;
|
||||
int order_;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/strutils.h"
|
||||
#include "jsonlyricsprovider.h"
|
||||
@@ -42,7 +43,9 @@
|
||||
#include "musixmatchlyricsprovider.h"
|
||||
#include "providers/musixmatchprovider.h"
|
||||
|
||||
MusixmatchLyricsProvider::MusixmatchLyricsProvider(NetworkAccessManager *network, QObject *parent) : JsonLyricsProvider("Musixmatch", true, false, network, parent), use_api_(true) {}
|
||||
using std::make_shared;
|
||||
|
||||
MusixmatchLyricsProvider::MusixmatchLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider("Musixmatch", true, false, network, parent), use_api_(true) {}
|
||||
|
||||
MusixmatchLyricsProvider::~MusixmatchLyricsProvider() {
|
||||
|
||||
@@ -57,7 +60,7 @@ MusixmatchLyricsProvider::~MusixmatchLyricsProvider() {
|
||||
|
||||
bool MusixmatchLyricsProvider::StartSearch(const int id, const LyricsSearchRequest &request) {
|
||||
|
||||
LyricsSearchContextPtr search = std::make_shared<LyricsSearchContext>();
|
||||
LyricsSearchContextPtr search = make_shared<LyricsSearchContext>();
|
||||
search->id = id;
|
||||
search->request = request;
|
||||
requests_search_.append(search);
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
@@ -31,6 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "lyricssearchresult.h"
|
||||
@@ -43,7 +42,7 @@ class MusixmatchLyricsProvider : public JsonLyricsProvider, public MusixmatchPro
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MusixmatchLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit MusixmatchLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~MusixmatchLyricsProvider() override;
|
||||
|
||||
bool StartSearch(const int id, const LyricsSearchRequest &request) override;
|
||||
@@ -58,7 +57,7 @@ class MusixmatchLyricsProvider : public JsonLyricsProvider, public MusixmatchPro
|
||||
LyricsSearchResults results;
|
||||
};
|
||||
|
||||
using LyricsSearchContextPtr = std::shared_ptr<LyricsSearchContext>;
|
||||
using LyricsSearchContextPtr = SharedPtr<LyricsSearchContext>;
|
||||
|
||||
bool SendSearchRequest(LyricsSearchContextPtr search);
|
||||
bool CreateLyricsRequest(LyricsSearchContextPtr search);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/strutils.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
@@ -37,7 +38,7 @@
|
||||
|
||||
const char *OVHLyricsProvider::kUrlSearch = "https://api.lyrics.ovh/v1/";
|
||||
|
||||
OVHLyricsProvider::OVHLyricsProvider(NetworkAccessManager *network, QObject *parent) : JsonLyricsProvider("Lyrics.ovh", true, false, network, parent) {}
|
||||
OVHLyricsProvider::OVHLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider("Lyrics.ovh", true, false, network, parent) {}
|
||||
|
||||
OVHLyricsProvider::~OVHLyricsProvider() {
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
|
||||
@@ -38,7 +39,7 @@ class OVHLyricsProvider : public JsonLyricsProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OVHLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit OVHLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~OVHLyricsProvider() override;
|
||||
|
||||
bool StartSearch(const int id, const LyricsSearchRequest &request) override;
|
||||
|
||||
Reference in New Issue
Block a user