Use QStringLiteral

This commit is contained in:
Jonas Kvinge
2024-04-09 23:20:26 +02:00
parent 3cfffa5fbb
commit 58944993b8
233 changed files with 3885 additions and 3885 deletions

View File

@@ -34,7 +34,7 @@ const char AzLyricsComLyricsProvider::kEndTag[] = "</div>";
const char AzLyricsComLyricsProvider::kLyricsStart[] = "<!-- Usage of azlyrics.com content by any third-party lyrics provider is prohibited by our licensing agreement. Sorry about that. -->";
AzLyricsComLyricsProvider::AzLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent)
: HtmlLyricsProvider("azlyrics.com", true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
: HtmlLyricsProvider(QStringLiteral("azlyrics.com"), true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
QUrl AzLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
@@ -44,6 +44,6 @@ QUrl AzLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
QString AzLyricsComLyricsProvider::StringFixup(const QString &text) {
return Utilities::Transliterate(text).remove(QRegularExpression("[^\\w0-9\\-]")).toLower();
return Utilities::Transliterate(text).remove(QRegularExpression(QStringLiteral("[^\\w0-9\\-]"))).toLower();
}

View File

@@ -39,7 +39,7 @@
const char *ChartLyricsProvider::kUrlSearch = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect";
ChartLyricsProvider::ChartLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : LyricsProvider("ChartLyrics", false, false, network, parent) {}
ChartLyricsProvider::ChartLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : LyricsProvider(QStringLiteral("ChartLyrics"), false, false, network, parent) {}
ChartLyricsProvider::~ChartLyricsProvider() {
@@ -55,8 +55,8 @@ ChartLyricsProvider::~ChartLyricsProvider() {
bool ChartLyricsProvider::StartSearch(const int id, const LyricsSearchRequest &request) {
QUrlQuery url_query;
url_query.addQueryItem("artist", QUrl::toPercentEncoding(request.artist));
url_query.addQueryItem("song", QUrl::toPercentEncoding(request.title));
url_query.addQueryItem(QStringLiteral("artist"), QUrl::toPercentEncoding(request.artist));
url_query.addQueryItem(QStringLiteral("song"), QUrl::toPercentEncoding(request.title));
QUrl url(kUrlSearch);
url.setQuery(url_query);
@@ -80,13 +80,13 @@ void ChartLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id,
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) {
Error(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
Error(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
emit SearchFinished(id);
return;
}
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
Error(QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
Error(QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
emit SearchFinished(id);
return;
}

View File

@@ -34,7 +34,7 @@ const char ElyricsNetLyricsProvider::kEndTag[] = "<\\/div>";
const char ElyricsNetLyricsProvider::kLyricsStart[] = "<div id='inlyr'>";
ElyricsNetLyricsProvider::ElyricsNetLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent)
: HtmlLyricsProvider("elyrics.net", true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
: HtmlLyricsProvider(QStringLiteral("elyrics.net"), true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
QUrl ElyricsNetLyricsProvider::Url(const LyricsSearchRequest &request) {
@@ -45,8 +45,8 @@ QUrl ElyricsNetLyricsProvider::Url(const LyricsSearchRequest &request) {
QString ElyricsNetLyricsProvider::StringFixup(const QString &text) {
return Utilities::Transliterate(text)
.replace(QRegularExpression("[^\\w0-9_,&\\-\\(\\) ]"), "_")
.replace(QRegularExpression(" {2,}"), " ")
.replace(QRegularExpression(QStringLiteral("[^\\w0-9_,&\\-\\(\\) ]")), QStringLiteral("_"))
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
.simplified()
.replace(' ', '-')
.toLower();

View File

@@ -61,7 +61,7 @@ const char *GeniusLyricsProvider::kUrlSearch = "https://api.genius.com/search/";
const char *GeniusLyricsProvider::kClientIDB64 = "RUNTNXU4U1VyMU1KUU5hdTZySEZteUxXY2hkanFiY3lfc2JjdXBpNG5WMU9SNUg4dTBZelEtZTZCdFg2dl91SQ==";
const char *GeniusLyricsProvider::kClientSecretB64 = "VE9pMU9vUjNtTXZ3eFR3YVN0QVRyUjVoUlhVWDI1Ylp5X240eEt1M0ZkYlNwRG5JUnd0LXFFbHdGZkZkRWY2VzJ1S011UnQzM3c2Y3hqY0tVZ3NGN2c=";
GeniusLyricsProvider::GeniusLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider("Genius", true, true, network, parent), server_(nullptr) {
GeniusLyricsProvider::GeniusLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider(QStringLiteral("Genius"), true, true, network, parent), server_(nullptr) {
QSettings s;
s.beginGroup(kSettingsGroup);
@@ -106,18 +106,18 @@ void GeniusLyricsProvider::Authenticate() {
}
QUrlQuery url_query;
url_query.addQueryItem("client_id", QUrl::toPercentEncoding(QByteArray::fromBase64(kClientIDB64)));
url_query.addQueryItem("redirect_uri", QUrl::toPercentEncoding(redirect_url.toString()));
url_query.addQueryItem("scope", "me");
url_query.addQueryItem("state", QUrl::toPercentEncoding(code_challenge_));
url_query.addQueryItem("response_type", "code");
url_query.addQueryItem(QStringLiteral("client_id"), QUrl::toPercentEncoding(QByteArray::fromBase64(kClientIDB64)));
url_query.addQueryItem(QStringLiteral("redirect_uri"), QUrl::toPercentEncoding(redirect_url.toString()));
url_query.addQueryItem(QStringLiteral("scope"), QStringLiteral("me"));
url_query.addQueryItem(QStringLiteral("state"), QUrl::toPercentEncoding(code_challenge_));
url_query.addQueryItem(QStringLiteral("response_type"), QStringLiteral("code"));
QUrl url(kOAuthAuthorizeUrl);
url.setQuery(url_query);
const bool result = QDesktopServices::openUrl(url);
if (!result) {
QMessageBox messagebox(QMessageBox::Information, tr("Genius Authentication"), tr("Please open this URL in your browser") + QString(":<br /><a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
QMessageBox messagebox(QMessageBox::Information, tr("Genius Authentication"), tr("Please open this URL in your browser") + QStringLiteral(":<br /><a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
messagebox.setTextFormat(Qt::RichText);
messagebox.exec();
}
@@ -132,10 +132,10 @@ void GeniusLyricsProvider::RedirectArrived() {
QUrl url = server_->request_url();
if (url.isValid()) {
QUrlQuery url_query(url);
if (url_query.hasQueryItem("error")) {
AuthError(QUrlQuery(url).queryItemValue("error"));
if (url_query.hasQueryItem(QStringLiteral("error"))) {
AuthError(QUrlQuery(url).queryItemValue(QStringLiteral("error")));
}
else if (url_query.hasQueryItem("code")) {
else if (url_query.hasQueryItem(QStringLiteral("code"))) {
QUrl redirect_url(kOAuthRedirectUrl);
redirect_url.setPort(server_->url().port());
RequestAccessToken(url, redirect_url);
@@ -164,17 +164,17 @@ void GeniusLyricsProvider::RequestAccessToken(const QUrl &url, const QUrl &redir
QUrlQuery url_query(url);
if (url.hasQuery() && url_query.hasQueryItem("code") && url_query.hasQueryItem("state")) {
if (url.hasQuery() && url_query.hasQueryItem(QStringLiteral("code")) && url_query.hasQueryItem(QStringLiteral("state"))) {
const QString code = url_query.queryItemValue("code");
const QString code = url_query.queryItemValue(QStringLiteral("code"));
QUrlQuery new_url_query;
new_url_query.addQueryItem("code", QUrl::toPercentEncoding(code));
new_url_query.addQueryItem("client_id", QUrl::toPercentEncoding(QByteArray::fromBase64(kClientIDB64)));
new_url_query.addQueryItem("client_secret", QUrl::toPercentEncoding(QByteArray::fromBase64(kClientSecretB64)));
new_url_query.addQueryItem("redirect_uri", QUrl::toPercentEncoding(redirect_url.toString()));
new_url_query.addQueryItem("grant_type", "authorization_code");
new_url_query.addQueryItem("response_type", "code");
new_url_query.addQueryItem(QStringLiteral("code"), QUrl::toPercentEncoding(code));
new_url_query.addQueryItem(QStringLiteral("client_id"), QUrl::toPercentEncoding(QByteArray::fromBase64(kClientIDB64)));
new_url_query.addQueryItem(QStringLiteral("client_secret"), QUrl::toPercentEncoding(QByteArray::fromBase64(kClientSecretB64)));
new_url_query.addQueryItem(QStringLiteral("redirect_uri"), QUrl::toPercentEncoding(redirect_url.toString()));
new_url_query.addQueryItem(QStringLiteral("grant_type"), QStringLiteral("authorization_code"));
new_url_query.addQueryItem(QStringLiteral("response_type"), QStringLiteral("code"));
QUrl new_url(kOAuthAccessTokenUrl);
QNetworkRequest req(new_url);
@@ -213,7 +213,7 @@ void GeniusLyricsProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
if (reply->error() != QNetworkReply::NoError || reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
if (reply->error() != QNetworkReply::NoError && reply->error() < 200) {
// This is a network error, there is nothing more to do.
AuthError(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
AuthError(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
return;
}
else {
@@ -223,18 +223,18 @@ void GeniusLyricsProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
if (json_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
QJsonObject json_obj = json_doc.object();
if (!json_obj.isEmpty() && json_obj.contains("error") && json_obj.contains("error_description")) {
QString error = json_obj["error"].toString();
QString error_description = json_obj["error_description"].toString();
login_errors_ << QString("Authentication failure: %1 (%2)").arg(error, error_description);
if (!json_obj.isEmpty() && json_obj.contains(QStringLiteral("error")) && json_obj.contains(QStringLiteral("error_description"))) {
QString error = json_obj[QStringLiteral("error")].toString();
QString error_description = json_obj[QStringLiteral("error_description")].toString();
login_errors_ << QStringLiteral("Authentication failure: %1 (%2)").arg(error, error_description);
}
}
if (login_errors_.isEmpty()) {
if (reply->error() != QNetworkReply::NoError) {
login_errors_ << QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
login_errors_ << QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error());
}
else {
login_errors_ << QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
login_errors_ << QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
}
}
AuthError();
@@ -248,32 +248,32 @@ void GeniusLyricsProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
if (json_error.error != QJsonParseError::NoError) {
Error(QString("Failed to parse Json data in authentication reply: %1").arg(json_error.errorString()));
Error(QStringLiteral("Failed to parse Json data in authentication reply: %1").arg(json_error.errorString()));
return;
}
if (json_doc.isEmpty()) {
AuthError("Authentication reply from server has empty Json document.");
AuthError(QStringLiteral("Authentication reply from server has empty Json document."));
return;
}
if (!json_doc.isObject()) {
AuthError("Authentication reply from server has Json document that is not an object.", json_doc);
AuthError(QStringLiteral("Authentication reply from server has Json document that is not an object."), json_doc);
return;
}
QJsonObject json_obj = json_doc.object();
if (json_obj.isEmpty()) {
AuthError("Authentication reply from server has empty Json object.", json_doc);
AuthError(QStringLiteral("Authentication reply from server has empty Json object."), json_doc);
return;
}
if (!json_obj.contains("access_token")) {
AuthError("Authentication reply from server is missing access token.", json_obj);
if (!json_obj.contains(QStringLiteral("access_token"))) {
AuthError(QStringLiteral("Authentication reply from server is missing access token."), json_obj);
return;
}
access_token_ = json_obj["access_token"].toString();
access_token_ = json_obj[QStringLiteral("access_token")].toString();
QSettings s;
s.beginGroup(kSettingsGroup);
@@ -297,7 +297,7 @@ bool GeniusLyricsProvider::StartSearch(const int id, const LyricsSearchRequest &
requests_search_.insert(id, search);
QUrlQuery url_query;
url_query.addQueryItem("q", QUrl::toPercentEncoding(QString("%1 %2").arg(request.artist, request.title)));
url_query.addQueryItem(QStringLiteral("q"), QUrl::toPercentEncoding(QStringLiteral("%1 %2").arg(request.artist, request.title)));
QUrl url(kUrlSearch);
url.setQuery(url_query);
@@ -330,78 +330,78 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id)
return;
}
if (!json_obj.contains("meta")) {
Error("Json reply is missing meta object.", json_obj);
if (!json_obj.contains(QStringLiteral("meta"))) {
Error(QStringLiteral("Json reply is missing meta object."), json_obj);
EndSearch(search);
return;
}
if (!json_obj["meta"].isObject()) {
Error("Json reply meta is not an object.", json_obj);
if (!json_obj[QStringLiteral("meta")].isObject()) {
Error(QStringLiteral("Json reply meta is not an object."), json_obj);
EndSearch(search);
return;
}
QJsonObject obj_meta = json_obj["meta"].toObject();
if (!obj_meta.contains("status")) {
Error("Json reply meta object is missing status.", obj_meta);
QJsonObject obj_meta = json_obj[QStringLiteral("meta")].toObject();
if (!obj_meta.contains(QStringLiteral("status"))) {
Error(QStringLiteral("Json reply meta object is missing status."), obj_meta);
EndSearch(search);
return;
}
int status = obj_meta["status"].toInt();
int status = obj_meta[QStringLiteral("status")].toInt();
if (status != 200) {
if (obj_meta.contains("message")) {
Error(QString("Received error %1: %2.").arg(status).arg(obj_meta["message"].toString()));
if (obj_meta.contains(QStringLiteral("message"))) {
Error(QStringLiteral("Received error %1: %2.").arg(status).arg(obj_meta[QStringLiteral("message")].toString()));
}
else {
Error(QString("Received error %1.").arg(status));
Error(QStringLiteral("Received error %1.").arg(status));
}
EndSearch(search);
return;
}
if (!json_obj.contains("response")) {
Error("Json reply is missing response.", json_obj);
if (!json_obj.contains(QStringLiteral("response"))) {
Error(QStringLiteral("Json reply is missing response."), json_obj);
EndSearch(search);
return;
}
if (!json_obj["response"].isObject()) {
Error("Json response is not an object.", json_obj);
if (!json_obj[QStringLiteral("response")].isObject()) {
Error(QStringLiteral("Json response is not an object."), json_obj);
EndSearch(search);
return;
}
QJsonObject obj_response = json_obj["response"].toObject();
if (!obj_response.contains("hits")) {
Error("Json response is missing hits.", obj_response);
QJsonObject obj_response = json_obj[QStringLiteral("response")].toObject();
if (!obj_response.contains(QStringLiteral("hits"))) {
Error(QStringLiteral("Json response is missing hits."), obj_response);
EndSearch(search);
return;
}
if (!obj_response["hits"].isArray()) {
Error("Json hits is not an array.", obj_response);
if (!obj_response[QStringLiteral("hits")].isArray()) {
Error(QStringLiteral("Json hits is not an array."), obj_response);
EndSearch(search);
return;
}
QJsonArray array_hits = obj_response["hits"].toArray();
QJsonArray array_hits = obj_response[QStringLiteral("hits")].toArray();
for (const QJsonValueRef value_hit : array_hits) {
if (!value_hit.isObject()) {
continue;
}
QJsonObject obj_hit = value_hit.toObject();
if (!obj_hit.contains("result")) {
if (!obj_hit.contains(QStringLiteral("result"))) {
continue;
}
if (!obj_hit["result"].isObject()) {
if (!obj_hit[QStringLiteral("result")].isObject()) {
continue;
}
QJsonObject obj_result = obj_hit["result"].toObject();
if (!obj_result.contains("title") || !obj_result.contains("primary_artist") || !obj_result.contains("url") || !obj_result["primary_artist"].isObject()) {
Error("Missing one or more values in result object", obj_result);
QJsonObject obj_result = obj_hit[QStringLiteral("result")].toObject();
if (!obj_result.contains(QStringLiteral("title")) || !obj_result.contains(QStringLiteral("primary_artist")) || !obj_result.contains(QStringLiteral("url")) || !obj_result[QStringLiteral("primary_artist")].isObject()) {
Error(QStringLiteral("Missing one or more values in result object"), obj_result);
continue;
}
QJsonObject primary_artist = obj_result["primary_artist"].toObject();
if (!primary_artist.contains("name")) continue;
QJsonObject primary_artist = obj_result[QStringLiteral("primary_artist")].toObject();
if (!primary_artist.contains(QStringLiteral("name"))) continue;
QString artist = primary_artist["name"].toString();
QString title = obj_result["title"].toString();
QString artist = primary_artist[QStringLiteral("name")].toString();
QString title = obj_result[QStringLiteral("title")].toString();
// Ignore results where both the artist and title don't match.
if (!artist.startsWith(search->request.albumartist, Qt::CaseInsensitive) &&
@@ -410,7 +410,7 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id)
continue;
}
QUrl url(obj_result["url"].toString());
QUrl url(obj_result[QStringLiteral("url")].toString());
if (!url.isValid()) continue;
if (search->requests_lyric_.contains(url)) continue;
@@ -450,27 +450,27 @@ void GeniusLyricsProvider::HandleLyricReply(QNetworkReply *reply, const int sear
const GeniusLyricsLyricContext lyric = search->requests_lyric_.value(url);
if (reply->error() != QNetworkReply::NoError) {
Error(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
Error(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
EndSearch(search, lyric);
return;
}
else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
Error(QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
Error(QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
EndSearch(search, lyric);
return;
}
QByteArray data = reply->readAll();
if (data.isEmpty()) {
Error("Empty reply received from server.");
Error(QStringLiteral("Empty reply received from server."));
EndSearch(search, lyric);
return;
}
QString content = QString::fromUtf8(data);
QString lyrics = HtmlLyricsProvider::ParseLyricsFromHTML(content, QRegularExpression("<div[^>]*>"), QRegularExpression("<\\/div>"), QRegularExpression("<div data-lyrics-container=[^>]+>"), true);
QString lyrics = HtmlLyricsProvider::ParseLyricsFromHTML(content, QRegularExpression(QStringLiteral("<div[^>]*>")), QRegularExpression(QStringLiteral("<\\/div>")), QRegularExpression(QStringLiteral("<div data-lyrics-container=[^>]+>")), true);
if (lyrics.isEmpty()) {
lyrics = HtmlLyricsProvider::ParseLyricsFromHTML(content, QRegularExpression("<div[^>]*>"), QRegularExpression("<\\/div>"), QRegularExpression("<div class=\"lyrics\">"), true);
lyrics = HtmlLyricsProvider::ParseLyricsFromHTML(content, QRegularExpression(QStringLiteral("<div[^>]*>")), QRegularExpression(QStringLiteral("<\\/div>")), QRegularExpression(QStringLiteral("<div class=\"lyrics\">")), true);
}
if (!lyrics.isEmpty()) {

View File

@@ -101,7 +101,7 @@ void HtmlLyricsProvider::HandleLyricsReply(QNetworkReply *reply, const int id, c
}
const QString lyrics = ParseLyricsFromHTML(QString::fromUtf8(data), QRegularExpression(start_tag_), QRegularExpression(end_tag_), QRegularExpression(lyrics_start_), multiple_);
if (lyrics.isEmpty() || lyrics.contains("we do not have the lyrics for", Qt::CaseInsensitive)) {
if (lyrics.isEmpty() || lyrics.contains(QLatin1String("we do not have the lyrics for"), Qt::CaseInsensitive)) {
qLog(Debug) << name_ << "No lyrics for" << request.artist << request.album << request.title;
emit SearchFinished(id);
return;
@@ -159,12 +159,12 @@ QString HtmlLyricsProvider::ParseLyricsFromHTML(const QString &content, const QR
lyrics.append(content.mid(start_lyrics_idx, end_lyrics_idx - start_lyrics_idx)
.remove('\r')
.remove('\n')
.remove(QRegularExpression("<a [^>]*>[^<]*</a>"))
.remove(QRegularExpression("<script>[^>]*</script>"))
.remove(QRegularExpression("<div [^>]*>×</div>"))
.replace(QRegularExpression("<br[^>]*>"), "\n")
.replace(QRegularExpression("</p>"), "\n\n")
.remove(QRegularExpression("<[^>]*>"))
.remove(QRegularExpression(QStringLiteral("<a [^>]*>[^<]*</a>")))
.remove(QRegularExpression(QStringLiteral("<script>[^>]*</script>")))
.remove(QRegularExpression(QStringLiteral("<div [^>]*>×</div>")))
.replace(QRegularExpression(QStringLiteral("<br[^>]*>")), QStringLiteral("\n"))
.replace(QRegularExpression(QStringLiteral("</p>")), QStringLiteral("\n\n"))
.remove(QRegularExpression(QStringLiteral("<[^>]*>")))
.trimmed());
}
else {
@@ -174,7 +174,7 @@ QString HtmlLyricsProvider::ParseLyricsFromHTML(const QString &content, const QR
}
while (start_idx > 0 && multiple);
if (lyrics.length() > 6000 || lyrics.contains("there are no lyrics to", Qt::CaseInsensitive)) {
if (lyrics.length() > 6000 || lyrics.contains(QLatin1String("there are no lyrics to"), Qt::CaseInsensitive)) {
return QString();
}

View File

@@ -36,13 +36,13 @@ JsonLyricsProvider::JsonLyricsProvider(const QString &name, const bool enabled,
QByteArray JsonLyricsProvider::ExtractData(QNetworkReply *reply) {
if (reply->error() != QNetworkReply::NoError) {
Error(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
Error(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
if (reply->error() < 200) {
return QByteArray();
}
}
else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
Error(QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
Error(QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
}
return reply->readAll();
@@ -59,23 +59,23 @@ QJsonObject JsonLyricsProvider::ExtractJsonObj(const QByteArray &data) {
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
if (json_error.error != QJsonParseError::NoError) {
Error(QString("Failed to parse json data: %1").arg(json_error.errorString()));
Error(QStringLiteral("Failed to parse json data: %1").arg(json_error.errorString()));
return QJsonObject();
}
if (json_doc.isEmpty()) {
Error("Received empty Json document.", data);
Error(QStringLiteral("Received empty Json document."), data);
return QJsonObject();
}
if (!json_doc.isObject()) {
Error("Json document is not an object.", json_doc);
Error(QStringLiteral("Json document is not an object."), json_doc);
return QJsonObject();
}
QJsonObject json_obj = json_doc.object();
if (json_obj.isEmpty()) {
Error("Received empty Json object.", json_doc);
Error(QStringLiteral("Received empty Json object."), json_doc);
return QJsonObject();
}

View File

@@ -35,7 +35,7 @@ const char LetrasLyricsProvider::kEndTag[] = "<\\/div>";
const char LetrasLyricsProvider::kLyricsStart[] = "<div id=\"letra-cnt\">";
LetrasLyricsProvider::LetrasLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent)
: HtmlLyricsProvider("letras.mus.br", true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
: HtmlLyricsProvider(QStringLiteral("letras.mus.br"), true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
QUrl LetrasLyricsProvider::Url(const LyricsSearchRequest &request) {
@@ -46,8 +46,8 @@ QUrl LetrasLyricsProvider::Url(const LyricsSearchRequest &request) {
QString LetrasLyricsProvider::StringFixup(const QString &text) {
return QUrl::toPercentEncoding(Utilities::Transliterate(text)
.replace(QRegularExpression("[^\\w0-9_,&\\-\\(\\) ]"), "_")
.replace(QRegularExpression(" {2,}"), " ")
.replace(QRegularExpression(QStringLiteral("[^\\w0-9_,&\\-\\(\\) ]")), QStringLiteral("_"))
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
.simplified()
.replace(' ', '-')
.toLower()

View File

@@ -39,7 +39,7 @@
const char *LoloLyricsProvider::kUrlSearch = "http://api.lololyrics.com/0.5/getLyric";
LoloLyricsProvider::LoloLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : LyricsProvider("LoloLyrics", true, false, network, parent) {}
LoloLyricsProvider::LoloLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : LyricsProvider(QStringLiteral("LoloLyrics"), true, false, network, parent) {}
LoloLyricsProvider::~LoloLyricsProvider() {
@@ -55,8 +55,8 @@ LoloLyricsProvider::~LoloLyricsProvider() {
bool LoloLyricsProvider::StartSearch(const int id, const LyricsSearchRequest &request) {
QUrlQuery url_query;
url_query.addQueryItem("artist", QUrl::toPercentEncoding(request.artist));
url_query.addQueryItem("track", QUrl::toPercentEncoding(request.title));
url_query.addQueryItem(QStringLiteral("artist"), QUrl::toPercentEncoding(request.artist));
url_query.addQueryItem(QStringLiteral("track"), QUrl::toPercentEncoding(request.title));
QUrl url(kUrlSearch);
url.setQuery(url_query);
@@ -81,7 +81,7 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id, c
QString failure_reason;
if (reply->error() != QNetworkReply::NoError) {
failure_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
failure_reason = QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error());
if (reply->error() < 200) {
Error(failure_reason);
emit SearchFinished(id);
@@ -89,7 +89,7 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id, c
}
}
else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
failure_reason = QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
failure_reason = QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
}
QByteArray data = reply->readAll();

View File

@@ -60,7 +60,7 @@ void LyricsFetcherSearch::TerminateSearch() {
void LyricsFetcherSearch::Start(SharedPtr<LyricsProviders> lyrics_providers) {
// Ignore Radio Paradise "commercial" break.
if (request_.artist.compare("commercial-free", Qt::CaseInsensitive) == 0 && request_.title.compare("listener-supported", Qt::CaseInsensitive) == 0) {
if (request_.artist.compare(QLatin1String("commercial-free"), Qt::CaseInsensitive) == 0 && request_.title.compare(QLatin1String("listener-supported"), Qt::CaseInsensitive) == 0) {
TerminateSearch();
return;
}

View File

@@ -45,7 +45,7 @@
using std::make_shared;
MusixmatchLyricsProvider::MusixmatchLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider("Musixmatch", true, false, network, parent), use_api_(true) {}
MusixmatchLyricsProvider::MusixmatchLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider(QStringLiteral("Musixmatch"), true, false, network, parent), use_api_(true) {}
MusixmatchLyricsProvider::~MusixmatchLyricsProvider() {
@@ -79,12 +79,12 @@ void MusixmatchLyricsProvider::CancelSearch(const int id) { Q_UNUSED(id); }
bool MusixmatchLyricsProvider::SendSearchRequest(LyricsSearchContextPtr search) {
QUrlQuery url_query;
url_query.addQueryItem("apikey", QByteArray::fromBase64(kApiKey));
url_query.addQueryItem("q_artist", QUrl::toPercentEncoding(search->request.artist));
url_query.addQueryItem("q_track", QUrl::toPercentEncoding(search->request.title));
url_query.addQueryItem("f_has_lyrics", "1");
url_query.addQueryItem(QStringLiteral("apikey"), QByteArray::fromBase64(kApiKey));
url_query.addQueryItem(QStringLiteral("q_artist"), QUrl::toPercentEncoding(search->request.artist));
url_query.addQueryItem(QStringLiteral("q_track"), QUrl::toPercentEncoding(search->request.title));
url_query.addQueryItem(QStringLiteral("f_has_lyrics"), QStringLiteral("1"));
QUrl url(QString(kApiUrl) + QString("/track.search"));
QUrl url(QString(kApiUrl) + QStringLiteral("/track.search"));
url.setQuery(url_query);
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
@@ -107,24 +107,24 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, LyricsSea
if (reply->error() != QNetworkReply::NoError) {
if (reply->error() == 401 || reply->error() == 402) {
Error(QString("Error %1 (%2) using API, switching to URL based lookup.").arg(reply->errorString()).arg(reply->error()));
Error(QStringLiteral("Error %1 (%2) using API, switching to URL based lookup.").arg(reply->errorString()).arg(reply->error()));
use_api_ = false;
CreateLyricsRequest(search);
return;
}
Error(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
Error(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
EndSearch(search);
return;
}
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 401 || reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 402) {
Error(QString("Received HTTP code %1 using API, switching to URL based lookup.").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
Error(QStringLiteral("Received HTTP code %1 using API, switching to URL based lookup.").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
use_api_ = false;
CreateLyricsRequest(search);
return;
}
Error(QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
Error(QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
EndSearch(search);
return;
}
@@ -136,61 +136,61 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, LyricsSea
return;
}
if (!json_obj.contains("message")) {
Error("Json reply is missing message object.", json_obj);
if (!json_obj.contains(QStringLiteral("message"))) {
Error(QStringLiteral("Json reply is missing message object."), json_obj);
EndSearch(search);
return;
}
if (!json_obj["message"].isObject()) {
Error("Json reply message is not an object.", json_obj);
if (!json_obj[QStringLiteral("message")].isObject()) {
Error(QStringLiteral("Json reply message is not an object."), json_obj);
EndSearch(search);
return;
}
QJsonObject obj_message = json_obj["message"].toObject();
QJsonObject obj_message = json_obj[QStringLiteral("message")].toObject();
if (!obj_message.contains("header")) {
Error("Json reply message object is missing header.", obj_message);
if (!obj_message.contains(QStringLiteral("header"))) {
Error(QStringLiteral("Json reply message object is missing header."), obj_message);
EndSearch(search);
return;
}
if (!obj_message["header"].isObject()) {
Error("Json reply message header is not an object.", obj_message);
if (!obj_message[QStringLiteral("header")].isObject()) {
Error(QStringLiteral("Json reply message header is not an object."), obj_message);
EndSearch(search);
return;
}
QJsonObject obj_header = obj_message["header"].toObject();
QJsonObject obj_header = obj_message[QStringLiteral("header")].toObject();
int status_code = obj_header["status_code"].toInt();
int status_code = obj_header[QStringLiteral("status_code")].toInt();
if (status_code != 200) {
Error(QString("Received status code %1, switching to URL based lookup.").arg(status_code));
Error(QStringLiteral("Received status code %1, switching to URL based lookup.").arg(status_code));
use_api_ = false;
CreateLyricsRequest(search);
return;
}
if (!obj_message.contains("body")) {
Error("Json reply is missing body.", json_obj);
if (!obj_message.contains(QStringLiteral("body"))) {
Error(QStringLiteral("Json reply is missing body."), json_obj);
EndSearch(search);
return;
}
if (!obj_message["body"].isObject()) {
Error("Json body is not an object.", json_obj);
if (!obj_message[QStringLiteral("body")].isObject()) {
Error(QStringLiteral("Json body is not an object."), json_obj);
EndSearch(search);
return;
}
QJsonObject obj_body = obj_message["body"].toObject();
QJsonObject obj_body = obj_message[QStringLiteral("body")].toObject();
if (!obj_body.contains("track_list")) {
Error("Json response is missing body.", obj_body);
if (!obj_body.contains(QStringLiteral("track_list"))) {
Error(QStringLiteral("Json response is missing body."), obj_body);
EndSearch(search);
return;
}
if (!obj_body["track_list"].isArray()) {
Error("Json hits is not an array.", obj_body);
if (!obj_body[QStringLiteral("track_list")].isArray()) {
Error(QStringLiteral("Json hits is not an array."), obj_body);
EndSearch(search);
return;
}
QJsonArray array_tracklist = obj_body["track_list"].toArray();
QJsonArray array_tracklist = obj_body[QStringLiteral("track_list")].toArray();
for (const QJsonValueRef value_track : array_tracklist) {
if (!value_track.isObject()) {
@@ -198,23 +198,23 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, LyricsSea
}
QJsonObject obj_track = value_track.toObject();
if (!obj_track.contains("track") || !obj_track["track"].isObject()) {
if (!obj_track.contains(QStringLiteral("track")) || !obj_track[QStringLiteral("track")].isObject()) {
continue;
}
obj_track = obj_track["track"].toObject();
if (!obj_track.contains("artist_name") ||
!obj_track.contains("album_name") ||
!obj_track.contains("track_name") ||
!obj_track.contains("track_share_url")) {
Error("Missing one or more values in result object", obj_track);
obj_track = obj_track[QStringLiteral("track")].toObject();
if (!obj_track.contains(QStringLiteral("artist_name")) ||
!obj_track.contains(QStringLiteral("album_name")) ||
!obj_track.contains(QStringLiteral("track_name")) ||
!obj_track.contains(QStringLiteral("track_share_url"))) {
Error(QStringLiteral("Missing one or more values in result object"), obj_track);
continue;
}
QString artist_name = obj_track["artist_name"].toString();
QString album_name = obj_track["album_name"].toString();
QString track_name = obj_track["track_name"].toString();
QUrl track_share_url(obj_track["track_share_url"].toString());
QString artist_name = obj_track[QStringLiteral("artist_name")].toString();
QString album_name = obj_track[QStringLiteral("album_name")].toString();
QString track_name = obj_track[QStringLiteral("track_name")].toString();
QUrl track_share_url(obj_track[QStringLiteral("track_share_url")].toString());
// Ignore results where both the artist, album and title don't match.
if (use_api_ &&
@@ -252,7 +252,7 @@ bool MusixmatchLyricsProvider::CreateLyricsRequest(LyricsSearchContextPtr search
return false;
}
QUrl url(QString("https://www.musixmatch.com/lyrics/%1/%2").arg(artist_stripped, title_stripped));
QUrl url(QStringLiteral("https://www.musixmatch.com/lyrics/%1/%2").arg(artist_stripped, title_stripped));
search->requests_lyrics_.append(url);
return SendLyricsRequest(search, url);
@@ -280,26 +280,26 @@ void MusixmatchLyricsProvider::HandleLyricsReply(QNetworkReply *reply, LyricsSea
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) {
Error(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
Error(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
EndSearch(search, url);
return;
}
else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
Error(QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
Error(QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
EndSearch(search, url);
return;
}
QByteArray data = reply->readAll();
if (data.isEmpty()) {
Error("Empty reply received from server.");
Error(QStringLiteral("Empty reply received from server."));
EndSearch(search, url);
return;
}
QString content = data;
QString data_begin = "<script id=\"__NEXT_DATA__\" type=\"application/json\">";
QString data_end = "</script>";
QString data_begin = QStringLiteral("<script id=\"__NEXT_DATA__\" type=\"application/json\">");
QString data_end = QStringLiteral("</script>");
qint64 begin_idx = content.indexOf(data_begin);
QString content_json;
if (begin_idx > 0) {
@@ -315,7 +315,7 @@ void MusixmatchLyricsProvider::HandleLyricsReply(QNetworkReply *reply, LyricsSea
return;
}
if (content_json.contains(QRegularExpression("<[^>]*>"))) { // Make sure it's not HTML code.
if (content_json.contains(QRegularExpression(QStringLiteral("<[^>]*>")))) { // Make sure it's not HTML code.
EndSearch(search, url);
return;
}
@@ -326,86 +326,86 @@ void MusixmatchLyricsProvider::HandleLyricsReply(QNetworkReply *reply, LyricsSea
return;
}
if (!obj_data.contains("props") || !obj_data["props"].isObject()) {
Error("Json reply is missing props.", obj_data);
if (!obj_data.contains(QStringLiteral("props")) || !obj_data[QStringLiteral("props")].isObject()) {
Error(QStringLiteral("Json reply is missing props."), obj_data);
EndSearch(search, url);
return;
}
obj_data = obj_data["props"].toObject();
obj_data = obj_data[QStringLiteral("props")].toObject();
if (!obj_data.contains("pageProps") || !obj_data["pageProps"].isObject()) {
Error("Json props is missing pageProps.", obj_data);
if (!obj_data.contains(QStringLiteral("pageProps")) || !obj_data[QStringLiteral("pageProps")].isObject()) {
Error(QStringLiteral("Json props is missing pageProps."), obj_data);
EndSearch(search, url);
return;
}
obj_data = obj_data["pageProps"].toObject();
obj_data = obj_data[QStringLiteral("pageProps")].toObject();
if (!obj_data.contains("data") || !obj_data["data"].isObject()) {
Error("Json pageProps is missing data.", obj_data);
if (!obj_data.contains(QStringLiteral("data")) || !obj_data[QStringLiteral("data")].isObject()) {
Error(QStringLiteral("Json pageProps is missing data."), obj_data);
EndSearch(search, url);
return;
}
obj_data = obj_data["data"].toObject();
obj_data = obj_data[QStringLiteral("data")].toObject();
if (!obj_data.contains("trackInfo") || !obj_data["trackInfo"].isObject()) {
Error("Json data is missing trackInfo.", obj_data);
if (!obj_data.contains(QStringLiteral("trackInfo")) || !obj_data[QStringLiteral("trackInfo")].isObject()) {
Error(QStringLiteral("Json data is missing trackInfo."), obj_data);
EndSearch(search, url);
return;
}
obj_data = obj_data["trackInfo"].toObject();
obj_data = obj_data[QStringLiteral("trackInfo")].toObject();
if (!obj_data.contains("data") || !obj_data["data"].isObject()) {
Error("Json trackInfo reply is missing data.", obj_data);
if (!obj_data.contains(QStringLiteral("data")) || !obj_data[QStringLiteral("data")].isObject()) {
Error(QStringLiteral("Json trackInfo reply is missing data."), obj_data);
EndSearch(search, url);
return;
}
obj_data = obj_data["data"].toObject();
obj_data = obj_data[QStringLiteral("data")].toObject();
if (!obj_data.contains("track") || !obj_data["track"].isObject()) {
Error("Json data is missing track.", obj_data);
if (!obj_data.contains(QStringLiteral("track")) || !obj_data[QStringLiteral("track")].isObject()) {
Error(QStringLiteral("Json data is missing track."), obj_data);
EndSearch(search, url);
return;
}
const QJsonObject obj_track = obj_data["track"].toObject();
const QJsonObject obj_track = obj_data[QStringLiteral("track")].toObject();
if (!obj_track.contains("hasLyrics") || !obj_track["hasLyrics"].isBool()) {
Error("Json track is missing hasLyrics.", obj_track);
if (!obj_track.contains(QStringLiteral("hasLyrics")) || !obj_track[QStringLiteral("hasLyrics")].isBool()) {
Error(QStringLiteral("Json track is missing hasLyrics."), obj_track);
EndSearch(search, url);
return;
}
const bool has_lyrics = obj_track["hasLyrics"].toBool();
const bool has_lyrics = obj_track[QStringLiteral("hasLyrics")].toBool();
if (!has_lyrics) {
EndSearch(search, url);
return;
}
LyricsSearchResult result;
if (obj_track.contains("artistName") && obj_track["artistName"].isString()) {
result.artist = obj_track["artistName"].toString();
if (obj_track.contains(QStringLiteral("artistName")) && obj_track[QStringLiteral("artistName")].isString()) {
result.artist = obj_track[QStringLiteral("artistName")].toString();
}
if (obj_track.contains("albumName") && obj_track["albumName"].isString()) {
result.album = obj_track["albumName"].toString();
if (obj_track.contains(QStringLiteral("albumName")) && obj_track[QStringLiteral("albumName")].isString()) {
result.album = obj_track[QStringLiteral("albumName")].toString();
}
if (obj_track.contains("name") && obj_track["name"].isString()) {
result.title = obj_track["name"].toString();
if (obj_track.contains(QStringLiteral("name")) && obj_track[QStringLiteral("name")].isString()) {
result.title = obj_track[QStringLiteral("name")].toString();
}
if (!obj_data.contains("lyrics") || !obj_data["lyrics"].isObject()) {
Error("Json data is missing lyrics.", obj_data);
if (!obj_data.contains(QStringLiteral("lyrics")) || !obj_data[QStringLiteral("lyrics")].isObject()) {
Error(QStringLiteral("Json data is missing lyrics."), obj_data);
EndSearch(search, url);
return;
}
QJsonObject obj_lyrics = obj_data["lyrics"].toObject();
QJsonObject obj_lyrics = obj_data[QStringLiteral("lyrics")].toObject();
if (!obj_lyrics.contains("body") || !obj_lyrics["body"].isString()) {
Error("Json lyrics reply is missing body.", obj_lyrics);
if (!obj_lyrics.contains(QStringLiteral("body")) || !obj_lyrics[QStringLiteral("body")].isString()) {
Error(QStringLiteral("Json lyrics reply is missing body."), obj_lyrics);
EndSearch(search, url);
return;
}
result.lyrics = obj_lyrics["body"].toString();
result.lyrics = obj_lyrics[QStringLiteral("body")].toString();
if (!result.lyrics.isEmpty()) {
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);

View File

@@ -38,7 +38,7 @@
const char *OVHLyricsProvider::kUrlSearch = "https://api.lyrics.ovh/v1/";
OVHLyricsProvider::OVHLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider("Lyrics.ovh", true, false, network, parent) {}
OVHLyricsProvider::OVHLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider(QStringLiteral("Lyrics.ovh"), true, false, network, parent) {}
OVHLyricsProvider::~OVHLyricsProvider() {
@@ -79,20 +79,20 @@ void OVHLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id, co
return;
}
if (json_obj.contains("error")) {
Error(json_obj["error"].toString());
if (json_obj.contains(QStringLiteral("error"))) {
Error(json_obj[QStringLiteral("error")].toString());
qLog(Debug) << "OVHLyrics: No lyrics for" << request.artist << request.title;
emit SearchFinished(id);
return;
}
if (!json_obj.contains("lyrics")) {
if (!json_obj.contains(QStringLiteral("lyrics"))) {
emit SearchFinished(id);
return;
}
LyricsSearchResult result;
result.lyrics = json_obj["lyrics"].toString();
result.lyrics = json_obj[QStringLiteral("lyrics")].toString();
if (result.lyrics.isEmpty()) {
qLog(Debug) << "OVHLyrics: No lyrics for" << request.artist << request.title;

View File

@@ -33,7 +33,7 @@ const char SongLyricsComLyricsProvider::kEndTag[] = "<\\/p>";
const char SongLyricsComLyricsProvider::kLyricsStart[] = "<p id=\"songLyricsDiv\"[^>]+>";
SongLyricsComLyricsProvider::SongLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent)
: HtmlLyricsProvider("songlyrics.com", true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
: HtmlLyricsProvider(QStringLiteral("songlyrics.com"), true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
QUrl SongLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
@@ -45,11 +45,11 @@ QString SongLyricsComLyricsProvider::StringFixup(QString text) {
return text.replace('/', '-')
.replace('\'', '-')
.remove(QRegularExpression("[^\\w0-9\\- ]"))
.replace(QRegularExpression(" {2,}"), " ")
.remove(QRegularExpression(QStringLiteral("[^\\w0-9\\- ]")))
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
.simplified()
.replace(' ', '-')
.replace(QRegularExpression("(-)\\1+"), "-")
.replace(QRegularExpression(QStringLiteral("(-)\\1+")), QStringLiteral("-"))
.toLower();
}