1
0
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:
Jonas Kvinge 2023-09-20 17:39:44 +02:00
parent 60fb83d770
commit da19272eb6
6 changed files with 14 additions and 9 deletions

View File

@ -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");

View File

@ -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[];

View File

@ -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);

View File

@ -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:

View File

@ -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/");

View File

@ -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[];