mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-29 16:49:27 +01:00
HtmlLyricsProvider: Rename GetUrl to Url
This commit is contained in:
parent
60fb83d770
commit
da19272eb6
@ -37,7 +37,7 @@ const char AzLyricsComLyricsProvider::kLyricsStart[] = "<!-- Usage of azlyrics.c
|
||||
AzLyricsComLyricsProvider::AzLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *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");
|
||||
|
||||
|
@ -39,8 +39,10 @@ class AzLyricsComLyricsProvider : public HtmlLyricsProvider {
|
||||
explicit AzLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
|
||||
protected:
|
||||
QUrl GetUrl(const LyricsSearchRequest &request) override;
|
||||
QString StringFixup(QString string) override;
|
||||
QUrl Url(const LyricsSearchRequest &request) override;
|
||||
|
||||
private:
|
||||
QString StringFixup(QString string);
|
||||
|
||||
private:
|
||||
static const char kUrl[];
|
||||
|
@ -51,7 +51,9 @@ HtmlLyricsProvider::~HtmlLyricsProvider() {
|
||||
|
||||
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);
|
||||
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
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);
|
||||
|
||||
protected:
|
||||
virtual QUrl GetUrl(const LyricsSearchRequest &request) = 0;
|
||||
virtual QString StringFixup(QString string) = 0;
|
||||
virtual QUrl Url(const LyricsSearchRequest &request) = 0;
|
||||
void Error(const QString &error, const QVariant &debug = QVariant()) override;
|
||||
|
||||
protected slots:
|
||||
|
@ -37,7 +37,7 @@ const char SongLyricsComLyricsProvider::kLyricsStart[] = "<p id=\"songLyricsDiv\
|
||||
SongLyricsComLyricsProvider::SongLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *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/");
|
||||
|
||||
|
@ -39,8 +39,10 @@ class SongLyricsComLyricsProvider : public HtmlLyricsProvider {
|
||||
explicit SongLyricsComLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
|
||||
protected:
|
||||
QUrl GetUrl(const LyricsSearchRequest &request) override;
|
||||
QString StringFixup(QString string) override;
|
||||
QUrl Url(const LyricsSearchRequest &request) override;
|
||||
|
||||
private:
|
||||
QString StringFixup(QString string);
|
||||
|
||||
private:
|
||||
static const char kUrl[];
|
||||
|
Loading…
x
Reference in New Issue
Block a user