lastfm: fix fetching artist info in language other than English
This commit is contained in:
3
NEWS
3
NEWS
@@ -19,7 +19,8 @@ ncmpcpp-0.8 (????-??-??)
|
||||
* Lyrics and last_fm can now be startup screens and are lockable.
|
||||
* Action 'update_environment' now also synchronizes status with MPD.
|
||||
* Fixed an issue that could cause some MPD events to be missed.
|
||||
* ACtion 'jump_to_playing_song' is not runnable now if there is no playing song.
|
||||
* Action 'jump_to_playing_song' is not runnable now if there is no playing song.
|
||||
* Fixed fetching artist info in language other than English.
|
||||
|
||||
ncmpcpp-0.7.7 (2016-10-31)
|
||||
* Fixed compilation on 32bit platforms.
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "lastfm_service.h"
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/locale/conversion.hpp>
|
||||
#include <fstream>
|
||||
@@ -52,7 +53,7 @@ Service::Result Service::fetch()
|
||||
url += "=";
|
||||
url += Curl::escape(arg.second);
|
||||
}
|
||||
|
||||
|
||||
std::string data;
|
||||
CURLcode code = Curl::perform(data, url);
|
||||
|
||||
@@ -63,7 +64,7 @@ Service::Result Service::fetch()
|
||||
else
|
||||
{
|
||||
result = processData(data);
|
||||
|
||||
|
||||
// if relevant part of data was not found and one of arguments
|
||||
// was language, try to fetch it again without that parameter.
|
||||
// otherwise just report failure.
|
||||
@@ -118,6 +119,10 @@ Service::Result ArtistInfo::processData(const std::string &data)
|
||||
std::string url = what[1], wiki;
|
||||
// unescape &s
|
||||
unescapeHtmlEntities(url);
|
||||
// fill in language info since url points to english version.
|
||||
const auto &lang = m_arguments["lang"];
|
||||
if (!lang.empty())
|
||||
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);
|
||||
|
||||
@@ -145,7 +150,10 @@ Service::Result ArtistInfo::processData(const std::string &data)
|
||||
result.second += desc;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.second += "No description available for this artist.";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user