diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a624c9d..9c1e5273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# ncmpcpp-0.10 (????-??-??) +* Add support for fetching lyrics from musixmatch.com. + # ncmpcpp-0.9 (2020-12-20) * Fix various Mopidy specific bugs. * Add `run_external_console_command` action for running terminal applications. diff --git a/doc/config b/doc/config index 45ab73ff..3c3afd35 100644 --- a/doc/config +++ b/doc/config @@ -405,7 +405,7 @@ # #cyclic_scrolling = no # -#lyrics_fetchers = azlyrics, genius, sing365, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, zeneszoveg, internet +#lyrics_fetchers = azlyrics, genius, musixmatch, sing365, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, zeneszoveg, internet # #follow_now_playing_lyrics = no # diff --git a/src/configuration.cpp b/src/configuration.cpp index ce0dfddf..c9eb3fef 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -158,6 +158,7 @@ bool configure(int argc, char **argv) std::vector> fetcher_data = { std::make_tuple("azlyrics", "rihanna", "umbrella"), std::make_tuple("genius", "rihanna", "umbrella"), + std::make_tuple("musixmatch", "rihanna", "umbrella"), std::make_tuple("sing365", "rihanna", "umbrella"), std::make_tuple("metrolyrics", "rihanna", "umbrella"), std::make_tuple("justsomelyrics", "rihanna", "umbrella"), diff --git a/src/lyrics_fetcher.cpp b/src/lyrics_fetcher.cpp index 4c8352f5..0cac946f 100644 --- a/src/lyrics_fetcher.cpp +++ b/src/lyrics_fetcher.cpp @@ -42,6 +42,8 @@ std::istream &operator>>(std::istream &is, LyricsFetcher_ &fetcher) fetcher = std::make_unique(); else if (s == "genius") fetcher = std::make_unique(); + else if (s == "musixmatch") + fetcher = std::make_unique(); else if (s == "sing365") fetcher = std::make_unique(); else if (s == "metrolyrics") @@ -83,7 +85,7 @@ LyricsFetcher::Result LyricsFetcher::fetch(const std::string &artist, result.second = curl_easy_strerror(code); return result; } - + auto lyrics = getContent(regex(), data); if (lyrics.empty() || notLyrics(data)) @@ -91,7 +93,7 @@ LyricsFetcher::Result LyricsFetcher::fetch(const std::string &artist, result.second = msgNotFound; return result; } - + data.clear(); for (auto it = lyrics.begin(); it != lyrics.end(); ++it) { @@ -183,7 +185,7 @@ LyricsFetcher::Result GoogleLyricsFetcher::fetch(const std::string &artist, result.second = msgNotFound; return result; } - + data = unescapeHtmlUtf8(urls[0]); URL = data.c_str(); diff --git a/src/lyrics_fetcher.h b/src/lyrics_fetcher.h index f2030683..046a92f7 100644 --- a/src/lyrics_fetcher.h +++ b/src/lyrics_fetcher.h @@ -69,6 +69,16 @@ private: const char *URL; }; +struct MusixmatchFetcher : public GoogleLyricsFetcher +{ + virtual const char *name() const override { return "musixmatch.com"; } + +protected: + virtual const char *regex() const override { return "(.*?)"; } + + virtual void postProcess(std::string &) const override { } +}; + struct MetrolyricsFetcher : public GoogleLyricsFetcher { virtual const char *name() const override { return "metrolyrics.com"; } diff --git a/src/settings.cpp b/src/settings.cpp index 33f40567..ed151b96 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -477,7 +477,7 @@ bool Configuration::read(const std::vector &config_paths, bool igno p.add("header_text_scrolling", &header_text_scrolling, "yes", yes_no); p.add("cyclic_scrolling", &use_cyclic_scrolling, "no", yes_no); p.add("lyrics_fetchers", &lyrics_fetchers, - "azlyrics, genius, sing365, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, zeneszoveg, internet", + "azlyrics, genius, musixmatch, sing365, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, zeneszoveg, internet", list_of); p.add("follow_now_playing_lyrics", &now_playing_lyrics, "no", yes_no); p.add("fetch_lyrics_for_current_song_in_background", &fetch_lyrics_in_background,