diff --git a/NEWS b/NEWS index ce5ace05..b130858f 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ ncmpcpp-0.6.6 (????-??-??) * A typo in the example configuration file was fixed. +* Fetching lyrics from lyricwiki.com was fixed. ncmpcpp-0.6.5 (2015-07-05) diff --git a/src/curl_handle.cpp b/src/curl_handle.cpp index 663a931f..7c64308f 100644 --- a/src/curl_handle.cpp +++ b/src/curl_handle.cpp @@ -35,7 +35,7 @@ namespace } } -CURLcode Curl::perform(std::string &data, const std::string &URL, const std::string &referer, unsigned timeout) +CURLcode Curl::perform(std::string &data, const std::string &URL, const std::string &referer, bool follow_redirect, unsigned timeout) { CURLcode result; CURL *c = curl_easy_init(); @@ -45,6 +45,8 @@ CURLcode Curl::perform(std::string &data, const std::string &URL, const std::str curl_easy_setopt(c, CURLOPT_CONNECTTIMEOUT, timeout); curl_easy_setopt(c, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(c, CURLOPT_USERAGENT, "ncmpcpp " VERSION); + if (follow_redirect) + curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L); if (!referer.empty()) curl_easy_setopt(c, CURLOPT_REFERER, referer.c_str()); result = curl_easy_perform(c); diff --git a/src/curl_handle.h b/src/curl_handle.h index c6f7b3d9..4b02f89e 100644 --- a/src/curl_handle.h +++ b/src/curl_handle.h @@ -30,7 +30,7 @@ namespace Curl { - CURLcode perform(std::string &data, const std::string &URL, const std::string &referer = "", unsigned timeout = 10); + CURLcode perform(std::string &data, const std::string &URL, const std::string &referer = "", bool follow_redirect = false, unsigned timeout = 10); std::string escape(const std::string &s); } diff --git a/src/lyrics_fetcher.cpp b/src/lyrics_fetcher.cpp index 2457092c..2a8ece54 100644 --- a/src/lyrics_fetcher.cpp +++ b/src/lyrics_fetcher.cpp @@ -118,7 +118,7 @@ LyricsFetcher::Result LyricwikiFetcher::fetch(const std::string &artist, const s result.first = false; std::string data; - CURLcode code = Curl::perform(data, result.second); + CURLcode code = Curl::perform(data, result.second, "", true); if (code != CURLE_OK) {