Create common class for Musixmatch

This commit is contained in:
Jonas Kvinge
2022-10-18 22:49:15 +02:00
parent d722035883
commit ec99df3144
7 changed files with 85 additions and 35 deletions

View File

@@ -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);