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

@@ -34,6 +34,7 @@
#include "core/logging.h"
#include "core/networkaccessmanager.h"
#include "providers/musixmatchprovider.h"
#include "albumcoverfetcher.h"
#include "jsoncoverprovider.h"
#include "musixmatchcoverprovider.h"
@@ -56,22 +57,10 @@ bool MusixmatchCoverProvider::StartSearch(const QString &artist, const QString &
Q_UNUSED(title);
QString artist_stripped = artist;
QString album_stripped = album;
if (artist.isEmpty() || album.isEmpty()) return false;
artist_stripped = artist_stripped.replace('/', '-')
.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption))
.simplified()
.replace(' ', '-')
.replace(QRegularExpression("(-)\\1+"), "-")
.toLower();
album_stripped = album_stripped.replace('/', '-')
.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption))
.simplified()
.replace(' ', '-')
.replace(QRegularExpression("(-)\\1+"), "-")
.toLower();
QString artist_stripped = StringFixup(artist);
QString album_stripped = StringFixup(album);
if (artist_stripped.isEmpty() || album_stripped.isEmpty()) return false;

View File

@@ -29,11 +29,12 @@
#include <QString>
#include "jsoncoverprovider.h"
#include "providers/musixmatchprovider.h"
class QNetworkReply;
class NetworkAccessManager;
class MusixmatchCoverProvider : public JsonCoverProvider {
class MusixmatchCoverProvider : public JsonCoverProvider, MusixmatchProvider {
Q_OBJECT
public: