mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-23 07:50:13 +01:00
lyrics: Add 30s timeout for lyrics provider requests
This commit is contained in:
parent
6675b1b63e
commit
0fc0dcdb79
@ -30,6 +30,7 @@ const int UltimateLyricsProvider::kRedirectLimit = 5;
|
|||||||
|
|
||||||
UltimateLyricsProvider::UltimateLyricsProvider()
|
UltimateLyricsProvider::UltimateLyricsProvider()
|
||||||
: network_(new NetworkAccessManager(this)),
|
: network_(new NetworkAccessManager(this)),
|
||||||
|
timeouts_(new NetworkTimeouts(30000, this)), // 30s
|
||||||
relevance_(0),
|
relevance_(0),
|
||||||
redirect_count_(0),
|
redirect_count_(0),
|
||||||
url_hop_(false) {}
|
url_hop_(false) {}
|
||||||
@ -57,6 +58,7 @@ void UltimateLyricsProvider::FetchInfo(int id, const Song& metadata) {
|
|||||||
QNetworkReply* reply = network_->get(QNetworkRequest(url));
|
QNetworkReply* reply = network_->get(QNetworkRequest(url));
|
||||||
connect(reply, &QNetworkReply::finished,
|
connect(reply, &QNetworkReply::finished,
|
||||||
[=] { this->RequestFinished(reply, url_text, id); });
|
[=] { this->RequestFinished(reply, url_text, id); });
|
||||||
|
timeouts_->AddReply(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply,
|
void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply,
|
||||||
@ -93,6 +95,7 @@ void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply,
|
|||||||
QNetworkReply* reply = network_->get(QNetworkRequest(target));
|
QNetworkReply* reply = network_->get(QNetworkRequest(target));
|
||||||
connect(reply, &QNetworkReply::finished,
|
connect(reply, &QNetworkReply::finished,
|
||||||
[=] { this->RequestFinished(reply, orig_url, id); });
|
[=] { this->RequestFinished(reply, orig_url, id); });
|
||||||
|
timeouts_->AddReply(reply);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +131,7 @@ void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply,
|
|||||||
QNetworkReply* reply = network_->get(QNetworkRequest(url));
|
QNetworkReply* reply = network_->get(QNetworkRequest(url));
|
||||||
connect(reply, &QNetworkReply::finished,
|
connect(reply, &QNetworkReply::finished,
|
||||||
[=] { this->RequestFinished(reply, orig_url, id); });
|
[=] { this->RequestFinished(reply, orig_url, id); });
|
||||||
|
timeouts_->AddReply(reply);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "songinfoprovider.h"
|
#include "songinfoprovider.h"
|
||||||
|
|
||||||
class NetworkAccessManager;
|
class NetworkAccessManager;
|
||||||
|
class NetworkTimeouts;
|
||||||
|
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
|
||||||
@ -86,6 +87,7 @@ class UltimateLyricsProvider : public SongInfoProvider {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
NetworkAccessManager* network_;
|
NetworkAccessManager* network_;
|
||||||
|
NetworkTimeouts* timeouts_;
|
||||||
|
|
||||||
QString name_;
|
QString name_;
|
||||||
QString title_;
|
QString title_;
|
||||||
|
Loading…
Reference in New Issue
Block a user