Add setting for lyric providers and add more providers

Fixes #335
This commit is contained in:
Jonas Kvinge
2020-05-08 18:35:36 +02:00
parent 6ef69f6b32
commit f44ce49ea7
39 changed files with 1834 additions and 105 deletions

View File

@@ -41,7 +41,7 @@
const char *LoloLyricsProvider::kUrlSearch = "http://api.lololyrics.com/0.5/getLyric";
LoloLyricsProvider::LoloLyricsProvider(QObject *parent) : LyricsProvider("LoloLyrics", parent), network_(new NetworkAccessManager(this)) {}
LoloLyricsProvider::LoloLyricsProvider(QObject *parent) : LyricsProvider("LoloLyrics", true, false, parent), network_(new NetworkAccessManager(this)) {}
bool LoloLyricsProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id) {
@@ -80,7 +80,8 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
if (reply->error() != QNetworkReply::NoError) {
failure_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
if (reply->error() < 200) {
Error(id, failure_reason);
Error(failure_reason);
emit SearchFinished(id, LyricsSearchResults());
return;
}
}
@@ -119,12 +120,6 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
else if (type == QXmlStreamReader::EndElement) {
if (name == "result") {
if (!result.lyrics.isEmpty()) {
if (result.artist.toLower() == artist.toLower())
result.score += 1.0;
if (result.title.toLower() == title.toLower())
result.score += 1.0;
if (result.lyrics.length() > LyricsFetcher::kGoodLyricsLength)
result.score += 1.0;
results << result;
}
result = LyricsSearchResult();
@@ -140,10 +135,9 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
}
void LoloLyricsProvider::Error(const quint64 id, const QString &error, const QVariant &debug) {
void LoloLyricsProvider::Error(const QString &error, const QVariant &debug) {
qLog(Error) << "LoloLyrics:" << error;
if (debug.isValid()) qLog(Debug) << debug;
emit SearchFinished(id, LyricsSearchResults());
}