mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-26 17:25:13 +01:00
lyrics: Use lambda for UltimateLyricsProvider requests
Remove map of requests to ids and pass info directly to reply handler.
This commit is contained in:
parent
40575e854e
commit
02a1fc9a07
@ -55,18 +55,11 @@ void UltimateLyricsProvider::FetchInfo(int id, const Song& metadata) {
|
|||||||
metadata_ = metadata;
|
metadata_ = metadata;
|
||||||
redirect_count_ = 0;
|
redirect_count_ = 0;
|
||||||
QNetworkReply* reply = network_->get(QNetworkRequest(url));
|
QNetworkReply* reply = network_->get(QNetworkRequest(url));
|
||||||
requests_[reply] = id;
|
connect(reply, &QNetworkReply::finished,
|
||||||
connect(reply, SIGNAL(finished()), SLOT(LyricsFetched()));
|
[=] { this->RequestFinished(reply, id); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void UltimateLyricsProvider::LyricsFetched() {
|
void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply, int id) {
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
|
|
||||||
if (!reply) {
|
|
||||||
url_hop_ = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int id = requests_.take(reply);
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
if (reply->error() != QNetworkReply::NoError) {
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
@ -94,8 +87,8 @@ void UltimateLyricsProvider::LyricsFetched() {
|
|||||||
|
|
||||||
redirect_count_++;
|
redirect_count_++;
|
||||||
QNetworkReply* reply = network_->get(QNetworkRequest(target));
|
QNetworkReply* reply = network_->get(QNetworkRequest(target));
|
||||||
requests_[reply] = id;
|
connect(reply, &QNetworkReply::finished,
|
||||||
connect(reply, SIGNAL(finished()), SLOT(LyricsFetched()));
|
[=] { this->RequestFinished(reply, id); });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,8 +122,8 @@ void UltimateLyricsProvider::LyricsFetched() {
|
|||||||
QUrl url(content);
|
QUrl url(content);
|
||||||
qLog(Debug) << "Next url hop: " << url;
|
qLog(Debug) << "Next url hop: " << url;
|
||||||
QNetworkReply* reply = network_->get(QNetworkRequest(url));
|
QNetworkReply* reply = network_->get(QNetworkRequest(url));
|
||||||
requests_[reply] = id;
|
connect(reply, &QNetworkReply::finished,
|
||||||
connect(reply, SIGNAL(finished()), SLOT(LyricsFetched()));
|
[=] { this->RequestFinished(reply, id); });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class UltimateLyricsProvider : public SongInfoProvider {
|
|||||||
void FetchInfo(int id, const Song& metadata);
|
void FetchInfo(int id, const Song& metadata);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void LyricsFetched();
|
void RequestFinished(QNetworkReply* reply, int id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ApplyExtractRule(const Rule& rule, QString* content) const;
|
bool ApplyExtractRule(const Rule& rule, QString* content) const;
|
||||||
@ -86,7 +86,6 @@ class UltimateLyricsProvider : public SongInfoProvider {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
NetworkAccessManager* network_;
|
NetworkAccessManager* network_;
|
||||||
QMap<QNetworkReply*, int> requests_;
|
|
||||||
|
|
||||||
QString name_;
|
QString name_;
|
||||||
QString title_;
|
QString title_;
|
||||||
|
Loading…
Reference in New Issue
Block a user