1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-14 10:24:19 +01:00

Code review comments from r2050

This commit is contained in:
David Sansome 2010-09-26 17:30:17 +00:00
parent bd273efe0d
commit f90f51197d
2 changed files with 22 additions and 22 deletions

View File

@ -42,14 +42,14 @@ LyricProvider::Result HtmlScraper::Search(const Song& metadata) const {
// Fill in fields in the URL
QString url_text(url_);
DoUrlReplace(&url_text, "{artist}", metadata.artist().toLower());
DoUrlReplace(&url_text, "{album}", metadata.album().toLower());
DoUrlReplace(&url_text, "{title}", metadata.title().toLower());
DoUrlReplace(&url_text, "{Artist}", metadata.artist());
DoUrlReplace(&url_text, "{Album}", metadata.album());
DoUrlReplace(&url_text, "{Title}", metadata.title());
DoUrlReplace(&url_text, "{Title2}", TitleCase(metadata.title()));
DoUrlReplace(&url_text, "{a}", FirstChar(metadata.artist()));
DoUrlReplace("{artist}", metadata.artist().toLower(), &url_text);
DoUrlReplace("{album}", metadata.album().toLower(), &url_text);
DoUrlReplace("{title}", metadata.title().toLower(), &url_text);
DoUrlReplace("{Artist}", metadata.artist(), &url_text);
DoUrlReplace("{Album}", metadata.album(), &url_text);
DoUrlReplace("{Title}", metadata.title(), &url_text);
DoUrlReplace("{Title2}", TitleCase(metadata.title()), &url_text);
DoUrlReplace("{a}", FirstChar(metadata.artist()), &url_text);
QUrl url(url_text);
@ -66,7 +66,9 @@ LyricProvider::Result HtmlScraper::Search(const Song& metadata) const {
return ret;
QVariant redirect_target = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (redirect_target.isValid()) {
if (!redirect_target.isValid())
break;
QUrl target = redirect_target.toUrl();
if (target.scheme().isEmpty() || target.host().isEmpty()) {
QString path = target.path();
@ -74,8 +76,6 @@ LyricProvider::Result HtmlScraper::Search(const Song& metadata) const {
target.setPath(path);
}
url = target;
} else
break;
}
const QString original_content = codec->toUnicode(reply->readAll());
@ -116,7 +116,7 @@ void HtmlScraper::ApplyExtractRule(const Rule& rule, QString* content) const {
}
QString HtmlScraper::ExtractXmlTag(const QString& source, const QString& tag) {
QRegExp re("<(\\w+).*>");
QRegExp re("<(\\w+).*>"); // ಠ_ಠ
if (re.indexIn(tag) == -1)
return QString();
@ -147,7 +147,7 @@ void HtmlScraper::ApplyExcludeRule(const Rule& rule, QString* content) const {
}
QString HtmlScraper::ExcludeXmlTag(const QString& source, const QString& tag) {
QRegExp re("<(\\w+).*>");
QRegExp re("<(\\w+).*>"); // ಠ_ಠ
if (re.indexIn(tag) == -1)
return source;
@ -180,8 +180,8 @@ QString HtmlScraper::TitleCase(const QString& text) {
return text[0].toUpper() + text.right(text.length() - 1).toLower();
}
void HtmlScraper::DoUrlReplace(QString* url, const QString& tag,
const QString& value) const {
void HtmlScraper::DoUrlReplace(const QString& tag, const QString& value,
QString* url) const {
if (!url->contains(tag))
return;

View File

@ -60,7 +60,7 @@ private:
static QString Exclude(const QString& source, const QString& begin, const QString& end);
static QString FirstChar(const QString& text);
static QString TitleCase(const QString& text);
void DoUrlReplace(QString* url, const QString& tag, const QString& value) const;
void DoUrlReplace(const QString& tag, const QString& value, QString* url) const;
private:
QString name_;