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

@@ -38,7 +38,7 @@
const char *OVHLyricsProvider::kUrlSearch = "https://api.lyrics.ovh/v1/";
OVHLyricsProvider::OVHLyricsProvider(QObject *parent) : JsonLyricsProvider("Lyrics.ovh", parent), network_(new NetworkAccessManager(this)) {}
OVHLyricsProvider::OVHLyricsProvider(QObject *parent) : JsonLyricsProvider("Lyrics.ovh", true, false, parent), network_(new NetworkAccessManager(this)) {}
bool OVHLyricsProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id) {
@@ -62,14 +62,14 @@ void OVHLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 id
reply->deleteLater();
QJsonObject json_obj = ExtractJsonObj(reply, id);
QJsonObject json_obj = ExtractJsonObj(reply);
if (json_obj.isEmpty()) {
emit SearchFinished(id, LyricsSearchResults());
return;
}
if (json_obj.contains("error")) {
Error(id, json_obj["error"].toString());
Error(json_obj["error"].toString());
qLog(Debug) << "OVHLyrics: No lyrics for" << artist << title;
emit SearchFinished(id, LyricsSearchResults());
return;
@@ -82,19 +82,17 @@ void OVHLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 id
LyricsSearchResult result;
result.lyrics = json_obj["lyrics"].toString();
if (result.lyrics.length() > LyricsFetcher::kGoodLyricsLength)
result.score += 1.0;
qLog(Debug) << "OVHLyrics: Got lyrics for" << artist << title;
emit SearchFinished(id, LyricsSearchResults() << result);
}
void OVHLyricsProvider::Error(const quint64 id, const QString &error, const QVariant &debug) {
void OVHLyricsProvider::Error(const QString &error, const QVariant &debug) {
qLog(Error) << "OVHLyrics:" << error;
if (debug.isValid()) qLog(Debug) << debug;
emit SearchFinished(id, LyricsSearchResults());
}