Improve lyrics match
This commit is contained in:
parent
1a07404c10
commit
505329730c
@ -26,6 +26,7 @@
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/transliterate.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "azlyricscomlyricsprovider.h"
|
||||
|
||||
@ -43,8 +44,8 @@ QUrl AzLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
|
||||
|
||||
}
|
||||
|
||||
QString AzLyricsComLyricsProvider::StringFixup(QString string) {
|
||||
QString AzLyricsComLyricsProvider::StringFixup(QString text) {
|
||||
|
||||
return string.remove(QRegularExpression("[^\\w0-9\\-]", QRegularExpression::UseUnicodePropertiesOption)).simplified().toLower();
|
||||
return Utilities::Transliterate(text).remove(QRegularExpression("[^\\w0-9\\-]")).toLower();
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class AzLyricsComLyricsProvider : public HtmlLyricsProvider {
|
||||
QUrl Url(const LyricsSearchRequest &request) override;
|
||||
|
||||
private:
|
||||
QString StringFixup(QString string);
|
||||
QString StringFixup(QString text);
|
||||
|
||||
private:
|
||||
static const char kUrl[];
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/transliterate.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "elyricsnetlyricsprovider.h"
|
||||
|
||||
@ -43,12 +44,13 @@ QUrl ElyricsNetLyricsProvider::Url(const LyricsSearchRequest &request) {
|
||||
|
||||
}
|
||||
|
||||
QString ElyricsNetLyricsProvider::StringFixup(QString string) {
|
||||
QString ElyricsNetLyricsProvider::StringFixup(QString text) {
|
||||
|
||||
return string
|
||||
.replace(' ', '-')
|
||||
.replace(QRegularExpression("[^\\w0-9_-]", QRegularExpression::UseUnicodePropertiesOption), "_")
|
||||
return Utilities::Transliterate(text)
|
||||
.replace(QRegularExpression("[^\\w0-9_,&\\-\\(\\) ]"), "_")
|
||||
.replace(QRegularExpression(" {2,}"), " ")
|
||||
.simplified()
|
||||
.replace(' ', '-')
|
||||
.toLower();
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class ElyricsNetLyricsProvider : public HtmlLyricsProvider {
|
||||
QUrl Url(const LyricsSearchRequest &request) override;
|
||||
|
||||
private:
|
||||
QString StringFixup(QString string);
|
||||
QString StringFixup(QString text);
|
||||
|
||||
private:
|
||||
static const char kUrl[];
|
||||
|
@ -43,12 +43,14 @@ QUrl LyricsModeComLyricsProvider::Url(const LyricsSearchRequest &request) {
|
||||
|
||||
}
|
||||
|
||||
QString LyricsModeComLyricsProvider::StringFixup(QString string) {
|
||||
QString LyricsModeComLyricsProvider::StringFixup(QString text) {
|
||||
|
||||
return string
|
||||
.replace(' ', '_')
|
||||
.remove(QRegularExpression("[^\\w0-9_-]", QRegularExpression::UseUnicodePropertiesOption))
|
||||
return text
|
||||
.remove(QRegularExpression("[^\\w0-9_\\- ]"))
|
||||
.replace(QRegularExpression(" {2,}"), " ")
|
||||
.simplified()
|
||||
.replace(' ', '_')
|
||||
.replace('-', '_')
|
||||
.toLower();
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class LyricsModeComLyricsProvider : public HtmlLyricsProvider {
|
||||
QUrl Url(const LyricsSearchRequest &request) override;
|
||||
|
||||
private:
|
||||
QString StringFixup(QString string);
|
||||
QString StringFixup(QString text);
|
||||
|
||||
private:
|
||||
static const char kUrl[];
|
||||
|
@ -43,14 +43,15 @@ QUrl SongLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
|
||||
|
||||
}
|
||||
|
||||
QString SongLyricsComLyricsProvider::StringFixup(QString string) {
|
||||
QString SongLyricsComLyricsProvider::StringFixup(QString text) {
|
||||
|
||||
return string.replace('/', '-')
|
||||
.replace('\'', '-')
|
||||
.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption))
|
||||
.simplified()
|
||||
.replace(' ', '-')
|
||||
.replace(QRegularExpression("(-)\\1+"), "-")
|
||||
.toLower();
|
||||
return text.replace('/', '-')
|
||||
.replace('\'', '-')
|
||||
.remove(QRegularExpression("[^\\w0-9\\- ]"))
|
||||
.replace(QRegularExpression(" {2,}"), " ")
|
||||
.simplified()
|
||||
.replace(' ', '-')
|
||||
.replace(QRegularExpression("(-)\\1+"), "-")
|
||||
.toLower();
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class SongLyricsComLyricsProvider : public HtmlLyricsProvider {
|
||||
QUrl Url(const LyricsSearchRequest &request) override;
|
||||
|
||||
private:
|
||||
QString StringFixup(QString string);
|
||||
QString StringFixup(QString text);
|
||||
|
||||
private:
|
||||
static const char kUrl[];
|
||||
|
@ -25,14 +25,15 @@
|
||||
const char *MusixmatchProvider::kApiUrl = "https://api.musixmatch.com/ws/1.1";
|
||||
const char *MusixmatchProvider::kApiKey = "Y2FhMDRlN2Y4OWE5OTIxYmZlOGMzOWQzOGI3ZGU4MjE=";
|
||||
|
||||
QString MusixmatchProvider::StringFixup(QString string) {
|
||||
QString MusixmatchProvider::StringFixup(QString text) {
|
||||
|
||||
return string.replace('/', '-')
|
||||
.replace('\'', '-')
|
||||
.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption))
|
||||
.simplified()
|
||||
.replace(' ', '-')
|
||||
.replace(QRegularExpression("(-)\\1+"), "-")
|
||||
.toLower();
|
||||
return text.replace('/', '-')
|
||||
.replace('\'', '-')
|
||||
.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption))
|
||||
.replace(QRegularExpression(" {2,}"), " ")
|
||||
.simplified()
|
||||
.replace(' ', '-')
|
||||
.replace(QRegularExpression("(-)\\1+"), "-")
|
||||
.toLower();
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
class MusixmatchProvider {
|
||||
|
||||
protected:
|
||||
QString StringFixup(QString string);
|
||||
QString StringFixup(QString text);
|
||||
|
||||
protected:
|
||||
static const char *kApiUrl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user