1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-25 13:08:34 +01:00

lyrics: Add debug info for lyric server replies

This commit is contained in:
Jim Broadus 2020-05-23 23:43:17 -07:00 committed by John Maguire
parent 02a1fc9a07
commit 6675b1b63e
2 changed files with 10 additions and 6 deletions

View File

@ -49,20 +49,22 @@ void UltimateLyricsProvider::FetchInfo(int id, const Song& metadata) {
ReplaceFields(metadata, &url_text);
QUrl url(url_text);
qLog(Debug) << "Fetching lyrics from" << url;
qLog(Debug) << "Fetching lyrics from" << url_text;
// Fetch the URL, follow redirects
metadata_ = metadata;
redirect_count_ = 0;
QNetworkReply* reply = network_->get(QNetworkRequest(url));
connect(reply, &QNetworkReply::finished,
[=] { this->RequestFinished(reply, id); });
[=] { this->RequestFinished(reply, url_text, id); });
}
void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply, int id) {
void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply,
const QString& orig_url, int id) {
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) {
qLog(Debug) << "Reply error" << reply->errorString();
url_hop_ = false;
emit Finished(id);
return;
@ -73,6 +75,8 @@ void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply, int id) {
reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (redirect_target.isValid()) {
if (redirect_count_ >= kRedirectLimit) {
qLog(Debug) << "Too many redirects from" << orig_url << "to"
<< reply->url().toString();
url_hop_ = false;
emit Finished(id);
return;
@ -88,7 +92,7 @@ void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply, int id) {
redirect_count_++;
QNetworkReply* reply = network_->get(QNetworkRequest(target));
connect(reply, &QNetworkReply::finished,
[=] { this->RequestFinished(reply, id); });
[=] { this->RequestFinished(reply, orig_url, id); });
return;
}
@ -123,7 +127,7 @@ void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply, int id) {
qLog(Debug) << "Next url hop: " << url;
QNetworkReply* reply = network_->get(QNetworkRequest(url));
connect(reply, &QNetworkReply::finished,
[=] { this->RequestFinished(reply, id); });
[=] { this->RequestFinished(reply, orig_url, id); });
return;
}

View File

@ -62,7 +62,7 @@ class UltimateLyricsProvider : public SongInfoProvider {
void FetchInfo(int id, const Song& metadata);
private slots:
void RequestFinished(QNetworkReply* reply, int id);
void RequestFinished(QNetworkReply* reply, const QString& orig_url, int id);
private:
bool ApplyExtractRule(const Rule& rule, QString* content) const;