From 985bc09b5c61d67cd179b1a6562c5949da2f368d Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 24 Jul 2024 20:33:32 +0200 Subject: [PATCH] Update lyrics fetchers Removes azlyrics, musixmatch, sing365/lyrics007 and metrolyrics. --- doc/config | 2 +- src/configuration.cpp | 6 +----- src/lyrics_fetcher.cpp | 24 +++++------------------- src/lyrics_fetcher.h | 40 ++-------------------------------------- src/settings.cpp | 2 +- 5 files changed, 10 insertions(+), 64 deletions(-) diff --git a/doc/config b/doc/config index 747f2055..82a80fcb 100644 --- a/doc/config +++ b/doc/config @@ -409,7 +409,7 @@ # #cyclic_scrolling = no # -#lyrics_fetchers = azlyrics, genius, musixmatch, sing365, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, zeneszoveg, internet +#lyrics_fetchers = genius, tekstowo, plyrics, justsomelyrics, jahlyrics, zeneszoveg, internet # #follow_now_playing_lyrics = no # diff --git a/src/configuration.cpp b/src/configuration.cpp index c9eb3fef..c1e26913 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -156,14 +156,10 @@ bool configure(int argc, char **argv) if (vm.count("test-lyrics-fetchers")) { 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"), std::make_tuple("jahlyrics", "sean kingston", "dry your eyes"), - std::make_tuple("plyrics", "offspring", "genocide"), + std::make_tuple("plyrics", "rihanna", "umbrella"), std::make_tuple("tekstowo", "rihanna", "umbrella"), std::make_tuple("zeneszoveg", "rihanna", "umbrella"), }; diff --git a/src/lyrics_fetcher.cpp b/src/lyrics_fetcher.cpp index 12a6fb2f..0f30f40d 100644 --- a/src/lyrics_fetcher.cpp +++ b/src/lyrics_fetcher.cpp @@ -38,16 +38,8 @@ std::istream &operator>>(std::istream &is, LyricsFetcher_ &fetcher) { std::string s; is >> s; - if (s == "azlyrics") - fetcher = std::make_unique(); - else if (s == "genius") + 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") - fetcher = std::make_unique(); else if (s == "justsomelyrics") fetcher = std::make_unique(); else if (s == "jahlyrics") @@ -76,7 +68,7 @@ LyricsFetcher::Result LyricsFetcher::fetch(const std::string &artist, std::string url = urlTemplate(); boost::replace_all(url, "%artist%", Curl::escape(artist)); boost::replace_all(url, "%title%", Curl::escape(title)); - + std::string data; CURLcode code = Curl::perform(data, url, "", true); @@ -88,9 +80,11 @@ LyricsFetcher::Result LyricsFetcher::fetch(const std::string &artist, auto lyrics = getContent(regex(), data); + //std::cerr << "URL: " << url << "\n"; + //std::cerr << "Data: " << data << "\n"; + if (lyrics.empty() || notLyrics(data)) { - //std::cerr << "Data: " << data << "\n"; //std::cerr << "Empty: " << lyrics.empty() << "\n"; //std::cerr << "Not Lyrics: " << notLyrics(data) << "\n"; result.second = msgNotFound; @@ -202,14 +196,6 @@ bool GoogleLyricsFetcher::isURLOk(const std::string &url) /**********************************************************************/ -bool MetrolyricsFetcher::isURLOk(const std::string &url) -{ - // it sometimes return link to sitemap.xml, which is huge so we need to discard it - return GoogleLyricsFetcher::isURLOk(url) && url.find("sitemap") == std::string::npos; -} - -/**********************************************************************/ - LyricsFetcher::Result InternetLyricsFetcher::fetch(const std::string &artist, const std::string &title) { diff --git a/src/lyrics_fetcher.h b/src/lyrics_fetcher.h index 672352ff..f4cfc0b2 100644 --- a/src/lyrics_fetcher.h +++ b/src/lyrics_fetcher.h @@ -69,34 +69,6 @@ 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"; } - -protected: - virtual const char *regex() const override { return "
(.*?)(.*?)(.*?)
"; } - - virtual bool isURLOk(const std::string &url) override; -}; - -struct Sing365Fetcher : public GoogleLyricsFetcher -{ - virtual const char *name() const override { return "lyrics007.com"; } - -protected: - virtual const char *regex() const override { return "
(.*?)
"; } -}; - struct JustSomeLyricsFetcher : public GoogleLyricsFetcher { virtual const char *name() const override { return "justsomelyrics.com"; } @@ -105,14 +77,6 @@ protected: virtual const char *regex() const override { return "
(.*?)See also"; } }; -struct AzLyricsFetcher : public GoogleLyricsFetcher -{ - virtual const char *name() const override { return "azlyrics.com"; } - -protected: - virtual const char *regex() const override { return "
.*?.*
(.*?)
"; } -}; - struct GeniusFetcher : public GoogleLyricsFetcher { virtual const char *name() const override { return "genius.com"; } @@ -142,7 +106,7 @@ struct TekstowoFetcher : public GoogleLyricsFetcher virtual const char *name() const override { return "tekstowo.pl"; } protected: - virtual const char *regex() const override { return "
.*?(.*?)(.*?)
"; } }; struct ZeneszovegFetcher : public GoogleLyricsFetcher @@ -150,7 +114,7 @@ struct ZeneszovegFetcher : public GoogleLyricsFetcher virtual const char *name() const override { return "zeneszoveg.hu"; } protected: - virtual const char *regex() const override { return "
(.*?)
"; } + virtual const char *regex() const override { return "
(.*?)