HtmlLyricsProvider: Rename GetUrl to Url
This commit is contained in:
@@ -37,7 +37,7 @@ const char AzLyricsComLyricsProvider::kLyricsStart[] = "<!-- Usage of azlyrics.c
|
|||||||
AzLyricsComLyricsProvider::AzLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent)
|
AzLyricsComLyricsProvider::AzLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||||
: HtmlLyricsProvider("azlyrics.com", true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
|
: HtmlLyricsProvider("azlyrics.com", true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
|
||||||
|
|
||||||
QUrl AzLyricsComLyricsProvider::GetUrl(const LyricsSearchRequest &request) {
|
QUrl AzLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
|
||||||
|
|
||||||
return QUrl(kUrl + StringFixup(request.artist) + "/" + StringFixup(request.title) + ".html");
|
return QUrl(kUrl + StringFixup(request.artist) + "/" + StringFixup(request.title) + ".html");
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,10 @@ class AzLyricsComLyricsProvider : public HtmlLyricsProvider {
|
|||||||
explicit AzLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
explicit AzLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QUrl GetUrl(const LyricsSearchRequest &request) override;
|
QUrl Url(const LyricsSearchRequest &request) override;
|
||||||
QString StringFixup(QString string) override;
|
|
||||||
|
private:
|
||||||
|
QString StringFixup(QString string);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char kUrl[];
|
static const char kUrl[];
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ HtmlLyricsProvider::~HtmlLyricsProvider() {
|
|||||||
|
|
||||||
bool HtmlLyricsProvider::StartSearch(const int id, const LyricsSearchRequest &request) {
|
bool HtmlLyricsProvider::StartSearch(const int id, const LyricsSearchRequest &request) {
|
||||||
|
|
||||||
QUrl url(GetUrl(request));
|
if (request.artist.isEmpty() || request.title.isEmpty()) return false;
|
||||||
|
|
||||||
|
QUrl url(Url(request));
|
||||||
QNetworkRequest req(url);
|
QNetworkRequest req(url);
|
||||||
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||||
QNetworkReply *reply = network_->get(req);
|
QNetworkReply *reply = network_->get(req);
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ class HtmlLyricsProvider : public LyricsProvider {
|
|||||||
static QString ParseLyricsFromHTML(const QString &content, const QRegularExpression &start_tag, const QRegularExpression &end_tag, const QRegularExpression &lyrics_start, const bool multiple);
|
static QString ParseLyricsFromHTML(const QString &content, const QRegularExpression &start_tag, const QRegularExpression &end_tag, const QRegularExpression &lyrics_start, const bool multiple);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QUrl GetUrl(const LyricsSearchRequest &request) = 0;
|
virtual QUrl Url(const LyricsSearchRequest &request) = 0;
|
||||||
virtual QString StringFixup(QString string) = 0;
|
|
||||||
void Error(const QString &error, const QVariant &debug = QVariant()) override;
|
void Error(const QString &error, const QVariant &debug = QVariant()) override;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const char SongLyricsComLyricsProvider::kLyricsStart[] = "<p id=\"songLyricsDiv\
|
|||||||
SongLyricsComLyricsProvider::SongLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent)
|
SongLyricsComLyricsProvider::SongLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||||
: HtmlLyricsProvider("songlyrics.com", true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
|
: HtmlLyricsProvider("songlyrics.com", true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
|
||||||
|
|
||||||
QUrl SongLyricsComLyricsProvider::GetUrl(const LyricsSearchRequest &request) {
|
QUrl SongLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
|
||||||
|
|
||||||
return QUrl(kUrl + StringFixup(request.artist) + "/" + StringFixup(request.title) + "-lyrics/");
|
return QUrl(kUrl + StringFixup(request.artist) + "/" + StringFixup(request.title) + "-lyrics/");
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,10 @@ class SongLyricsComLyricsProvider : public HtmlLyricsProvider {
|
|||||||
explicit SongLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
explicit SongLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QUrl GetUrl(const LyricsSearchRequest &request) override;
|
QUrl Url(const LyricsSearchRequest &request) override;
|
||||||
QString StringFixup(QString string) override;
|
|
||||||
|
private:
|
||||||
|
QString StringFixup(QString string);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char kUrl[];
|
static const char kUrl[];
|
||||||
|
|||||||
Reference in New Issue
Block a user