Fix fetching information about artists from last.fm

This commit is contained in:
Andrzej Rybczak
2020-12-23 01:11:14 +01:00
parent 7e4f3b1917
commit 11e3ba562a
3 changed files with 6 additions and 8 deletions

View File

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

View File

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

View File

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