Improve lyrics match

This commit is contained in:
Jonas Kvinge
2023-10-08 23:55:05 +02:00
parent 1a07404c10
commit 505329730c
10 changed files with 38 additions and 31 deletions

View File

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