Create common class for Musixmatch
This commit is contained in:
@@ -39,9 +39,7 @@
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "lyricsfetcher.h"
|
||||
#include "musixmatchlyricsprovider.h"
|
||||
|
||||
const char *MusixmatchLyricsProvider::kApiUrl = "https://api.musixmatch.com/ws/1.1";
|
||||
const char *MusixmatchLyricsProvider::kApiKey = "Y2FhMDRlN2Y4OWE5OTIxYmZlOGMzOWQzOGI3ZGU4MjE=";
|
||||
#include "providers/musixmatchprovider.h"
|
||||
|
||||
MusixmatchLyricsProvider::MusixmatchLyricsProvider(NetworkAccessManager *network, QObject *parent) : JsonLyricsProvider("Musixmatch", true, false, network, parent), rate_limit_exceeded_(false) {}
|
||||
|
||||
@@ -247,18 +245,6 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, LyricsSea
|
||||
|
||||
}
|
||||
|
||||
QString MusixmatchLyricsProvider::StringFixup(QString string) {
|
||||
|
||||
return string.replace('/', '-')
|
||||
.replace('\'', '-')
|
||||
.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption))
|
||||
.simplified()
|
||||
.replace(' ', '-')
|
||||
.replace(QRegularExpression("(-)\\1+"), "-")
|
||||
.toLower();
|
||||
|
||||
}
|
||||
|
||||
bool MusixmatchLyricsProvider::CreateLyricsRequest(LyricsSearchContextPtr search) {
|
||||
|
||||
QString artist_stripped = StringFixup(search->artist);
|
||||
|
||||
@@ -33,11 +33,12 @@
|
||||
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "lyricsfetcher.h"
|
||||
#include "providers/musixmatchprovider.h"
|
||||
|
||||
class QNetworkReply;
|
||||
class NetworkAccessManager;
|
||||
|
||||
class MusixmatchLyricsProvider : public JsonLyricsProvider {
|
||||
class MusixmatchLyricsProvider : public JsonLyricsProvider, public MusixmatchProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -60,7 +61,6 @@ class MusixmatchLyricsProvider : public JsonLyricsProvider {
|
||||
|
||||
using LyricsSearchContextPtr = std::shared_ptr<LyricsSearchContext>;
|
||||
|
||||
QString StringFixup(QString string);
|
||||
bool SendSearchRequest(LyricsSearchContextPtr search);
|
||||
bool CreateLyricsRequest(LyricsSearchContextPtr search);
|
||||
bool SendLyricsRequest(LyricsSearchContextPtr search, const QUrl &url);
|
||||
@@ -72,8 +72,6 @@ class MusixmatchLyricsProvider : public JsonLyricsProvider {
|
||||
void HandleLyricsReply(QNetworkReply *reply, LyricsSearchContextPtr search, const QUrl &url);
|
||||
|
||||
private:
|
||||
static const char *kApiUrl;
|
||||
static const char *kApiKey;
|
||||
QList<LyricsSearchContextPtr> requests_search_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
bool rate_limit_exceeded_;
|
||||
|
||||
Reference in New Issue
Block a user