diff --git a/NEWS b/NEWS index c0d58002..f8d4dbd1 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ ncmpcpp-0.7.6 (????-??-??) * Opening playlist editor when there is no MPD playlists directory no longer freezes the application. * Added info about behavior of MPD_HOST and MPD_PORT environment variables to man page. * Tilde will now be expanded to home directory in visualizer_fifo_path, execute_on_song_change and external_editor configuration variables. +* Fixed lyricwiki and justsomelyrics fetchers. ncmpcpp-0.7.5 (2016-08-17) * Action chains can be now used for seeking. diff --git a/src/lyrics_fetcher.cpp b/src/lyrics_fetcher.cpp index 7e1859fe..f41a9a2b 100644 --- a/src/lyrics_fetcher.cpp +++ b/src/lyrics_fetcher.cpp @@ -25,7 +25,9 @@ #include #include +#include #include +#include #include #include @@ -105,6 +107,15 @@ std::vector LyricsFetcher::getContent(const char *regex_, const std void LyricsFetcher::postProcess(std::string &data) const { stripHtmlTags(data); + // Remove indentation from each line and collapse multiple newlines into one. + std::vector lines; + boost::split(lines, data, boost::is_any_of("\r\n")); + for (auto &line : lines) + boost::trim(line); + std::unique(lines.begin(), lines.end(), [](std::string &a, std::string &b) { + return a.empty() && b.empty(); + }); + data = boost::algorithm::join(lines, "\n"); boost::trim(data); } @@ -126,7 +137,7 @@ LyricsFetcher::Result LyricwikiFetcher::fetch(const std::string &artist, const s return result; } - auto lyrics = getContent("
(.*?)