summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Rybczak <andrzej@rybczak.net>2020-12-23 01:11:14 +0100
committerAndrzej Rybczak <andrzej@rybczak.net>2020-12-23 01:11:14 +0100
commit11e3ba562aeed7feefeda7a6d4847db611761ac1 (patch)
treea11c65d1ca116bc6e254971e5fb0d0fdb88f7946
parent7e4f3b1917f389f8769dff1cd738d93f5d365377 (diff)
Fix fetching information about artists from last.fm
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/lastfm_service.cpp12
-rw-r--r--src/utility/html.cpp1
3 files changed, 6 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1f89bdc2..dcbd8029 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
* Enable Link Time Optimization by default.
* Enable full sorting of items in the local browser if it's not.
* Bind `Play` to `Backspace` by default.
+* Fix fetching information about artists from last.fm.
# ncmpcpp-0.9 (2020-12-20)
* Fix various Mopidy specific bugs.
diff --git a/src/lastfm_service.cpp b/src/lastfm_service.cpp
index 39432adc..ace3cb89 100644
--- a/src/lastfm_service.cpp
+++ b/src/lastfm_service.cpp
@@ -120,11 +120,11 @@ Service::Result ArtistInfo::processData(const std::string &data)
unescapeHtmlEntities(url);
// fill in language info since url points to english version.
const auto &lang = m_arguments["lang"];
- if (!lang.empty())
+ if (!lang.empty() && lang != "en")
boost::replace_first(url, "last.fm/music/", "last.fm/" + lang + "/music/");
// ...try to get the content of it...
CURLcode code = Curl::perform(wiki, url, "", true);
-
+
if (code != CURLE_OK)
{
result.second = curl_easy_strerror(code);
@@ -138,13 +138,9 @@ Service::Result ArtistInfo::processData(const std::string &data)
desc = unescapeHtmlUtf8(what[1]);
}
}
- else
- {
- // otherwise, get rid of CDATA wrapper.
- rx.assign("<!\\[CDATA\\[(.*)\\]\\]>");
- desc = boost::regex_replace(desc, rx, "\\1");
- }
stripHtmlTags(desc);
+ // Needs to be done after stripHtmlTags in case there are &#10;s there.
+ desc = unescapeHtmlUtf8(desc);
boost::trim(desc);
result.second += desc;
}
diff --git a/src/utility/html.cpp b/src/utility/html.cpp
index 031f258e..9ef71bec 100644
--- a/src/utility/html.cpp
+++ b/src/utility/html.cpp
@@ -54,6 +54,7 @@ std::string unescapeHtmlUtf8(const std::string &data)
void unescapeHtmlEntities(std::string &s)
{
// well, at least some of them.
+ boost::replace_all(s, "&apos;", "'");
boost::replace_all(s, "&amp;", "&");
boost::replace_all(s, "&gt;", ">");
boost::replace_all(s, "&lt;", "<");