Increase lyrics score if lyrics text > 60

This commit is contained in:
Jonas Kvinge 2020-01-02 19:21:27 +01:00
parent 7f442cff3b
commit 443be1c2c8
6 changed files with 13 additions and 0 deletions

View File

@ -113,6 +113,7 @@ void AuddLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
result.score = 0.0; result.score = 0.0;
if (result.artist.toLower() == artist.toLower()) result.score += 1.0; if (result.artist.toLower() == artist.toLower()) result.score += 1.0;
if (result.title.toLower() == title.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;
//qLog(Debug) << "AudDLyrics:" << result.artist << result.title << result.lyrics.length(); //qLog(Debug) << "AudDLyrics:" << result.artist << result.title << result.lyrics.length();
results << result; results << result;

View File

@ -112,6 +112,7 @@ void ChartLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64
result.score = 0.0; result.score = 0.0;
if (result.artist.toLower() == artist.toLower()) result.score += 1.0; if (result.artist.toLower() == artist.toLower()) result.score += 1.0;
if (result.title.toLower() == title.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;
if (result.artist.toLower() == artist.toLower() || result.title.toLower() == title.toLower()) { if (result.artist.toLower() == artist.toLower() || result.title.toLower() == title.toLower()) {
results << result; results << result;
} }

View File

@ -119,6 +119,12 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
else if (type == QXmlStreamReader::EndElement) { else if (type == QXmlStreamReader::EndElement) {
if (name == "result") { if (name == "result") {
if (!result.lyrics.isEmpty()) { 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; results << result;
} }
result = LyricsSearchResult(); result = LyricsSearchResult();

View File

@ -30,6 +30,7 @@
#include "lyricsfetchersearch.h" #include "lyricsfetchersearch.h"
const int LyricsFetcher::kMaxConcurrentRequests = 5; const int LyricsFetcher::kMaxConcurrentRequests = 5;
const int LyricsFetcher::kGoodLyricsLength = 60;
LyricsFetcher::LyricsFetcher(LyricsProviders *lyrics_providers, QObject *parent) LyricsFetcher::LyricsFetcher(LyricsProviders *lyrics_providers, QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -65,6 +65,7 @@ class LyricsFetcher : public QObject {
virtual ~LyricsFetcher() {} virtual ~LyricsFetcher() {}
static const int kMaxConcurrentRequests; static const int kMaxConcurrentRequests;
static const int kGoodLyricsLength;
quint64 Search(const QString &artist, const QString &album, const QString &title); quint64 Search(const QString &artist, const QString &album, const QString &title);
void Clear(); void Clear();

View File

@ -87,6 +87,9 @@ void OVHLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 id
LyricsSearchResult result; LyricsSearchResult result;
result.lyrics = json_obj["lyrics"].toString(); result.lyrics = json_obj["lyrics"].toString();
if (result.lyrics.length() > LyricsFetcher::kGoodLyricsLength)
result.score += 1.0;
qLog(Debug) << "OVHLyrics: Got lyrics for" << artist << title; qLog(Debug) << "OVHLyrics: Got lyrics for" << artist << title;
emit SearchFinished(id, LyricsSearchResults() << result); emit SearchFinished(id, LyricsSearchResults() << result);