Merge branch '0.6.x'
This commit is contained in:
3
NEWS
3
NEWS
@@ -32,6 +32,9 @@ ncmpcpp-0.7 (????-??-??)
|
|||||||
* Output of the visualizer now scales automatically as long as 'visualizer_sample_multiplier' is set to 1.
|
* Output of the visualizer now scales automatically as long as 'visualizer_sample_multiplier' is set to 1.
|
||||||
* Command line switch that prints current song to the standard output is available once again.
|
* Command line switch that prints current song to the standard output is available once again.
|
||||||
|
|
||||||
|
ncmpcpp-0.6.7 (2015-09-12)
|
||||||
|
* Fetching artist info from last.fm was fixed.
|
||||||
|
|
||||||
ncmpcpp-0.6.6 (2015-09-07)
|
ncmpcpp-0.6.6 (2015-09-07)
|
||||||
* A typo in the example configuration file was fixed.
|
* A typo in the example configuration file was fixed.
|
||||||
* Fetching lyrics from lyricwiki.com was fixed.
|
* Fetching lyrics from lyricwiki.com was fixed.
|
||||||
|
|||||||
@@ -116,9 +116,11 @@ Service::Result ArtistInfo::processData(const std::string &data)
|
|||||||
rx.assign("<link rel=\"original\" href=\"(.*?)\"");
|
rx.assign("<link rel=\"original\" href=\"(.*?)\"");
|
||||||
if (boost::regex_search(data, what, rx))
|
if (boost::regex_search(data, what, rx))
|
||||||
{
|
{
|
||||||
|
std::string url = what[1], wiki;
|
||||||
|
// unescape &s
|
||||||
|
unescapeHtmlEntities(url);
|
||||||
// ...try to get the content of it...
|
// ...try to get the content of it...
|
||||||
std::string wiki;
|
CURLcode code = Curl::perform(wiki, url, "", true);
|
||||||
CURLcode code = Curl::perform(wiki, what[1]);
|
|
||||||
|
|
||||||
if (code != CURLE_OK)
|
if (code != CURLE_OK)
|
||||||
{
|
{
|
||||||
@@ -128,7 +130,7 @@ Service::Result ArtistInfo::processData(const std::string &data)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ...and filter it to get the whole description.
|
// ...and filter it to get the whole description.
|
||||||
rx.assign("<div id=\"wiki\">(.*?)</div>");
|
rx.assign("<div class=\"wiki\">(.*?)</div>");
|
||||||
if (boost::regex_search(wiki, what, rx))
|
if (boost::regex_search(wiki, what, rx))
|
||||||
desc = unescapeHtmlUtf8(what[1]);
|
desc = unescapeHtmlUtf8(what[1]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include "utility/html.h"
|
#include "utility/html.h"
|
||||||
//#include "utility/string.h"
|
|
||||||
|
|
||||||
std::string unescapeHtmlUtf8(const std::string &data)
|
std::string unescapeHtmlUtf8(const std::string &data)
|
||||||
{
|
{
|
||||||
@@ -51,18 +50,28 @@ std::string unescapeHtmlUtf8(const std::string &data)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unescapeHtmlEntities(std::string &s)
|
||||||
|
{
|
||||||
|
// well, at least some of them.
|
||||||
|
boost::replace_all(s, "&", "&");
|
||||||
|
boost::replace_all(s, ">", ">");
|
||||||
|
boost::replace_all(s, "<", "<");
|
||||||
|
boost::replace_all(s, " ", " ");
|
||||||
|
boost::replace_all(s, """, "\"");
|
||||||
|
}
|
||||||
|
|
||||||
void stripHtmlTags(std::string &s)
|
void stripHtmlTags(std::string &s)
|
||||||
{
|
{
|
||||||
bool erase = 0;
|
bool erase = 0;
|
||||||
for (size_t i = s.find("<"); i != std::string::npos; i = s.find("<"))
|
for (size_t i = s.find("<"); i != std::string::npos; i = s.find("<"))
|
||||||
{
|
{
|
||||||
size_t j = s.find(">", i)+1;
|
size_t j = s.find(">", i)+1;
|
||||||
s.replace(i, j-i, "");
|
if (s.compare(i, j-i, "<p>") == 0 || s.compare(i, j-i, "</p>") == 0)
|
||||||
|
s.replace(i, j-i, "\n");
|
||||||
|
else
|
||||||
|
s.replace(i, j-i, "");
|
||||||
}
|
}
|
||||||
boost::replace_all(s, "'", "'");
|
unescapeHtmlEntities(s);
|
||||||
boost::replace_all(s, "&", "&");
|
|
||||||
boost::replace_all(s, """, "\"");
|
|
||||||
boost::replace_all(s, " ", " ");
|
|
||||||
for (size_t i = 0; i < s.length(); ++i)
|
for (size_t i = 0; i < s.length(); ++i)
|
||||||
{
|
{
|
||||||
if (erase)
|
if (erase)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
std::string unescapeHtmlUtf8(const std::string &s);
|
std::string unescapeHtmlUtf8(const std::string &s);
|
||||||
|
void unescapeHtmlEntities(std::string &s);
|
||||||
void stripHtmlTags(std::string &s);
|
void stripHtmlTags(std::string &s);
|
||||||
|
|
||||||
#endif // NCMPCPP_UTILITY_HTML_H
|
#endif // NCMPCPP_UTILITY_HTML_H
|
||||||
|
|||||||
Reference in New Issue
Block a user