Update lyrics fetchers

Removes azlyrics, musixmatch, sing365/lyrics007 and metrolyrics.
This commit is contained in:
Andrzej Rybczak
2024-07-24 20:33:32 +02:00
parent b2c8ca91c4
commit 985bc09b5c
5 changed files with 10 additions and 64 deletions

View File

@@ -409,7 +409,7 @@
# #
#cyclic_scrolling = no #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 #follow_now_playing_lyrics = no
# #

View File

@@ -156,14 +156,10 @@ bool configure(int argc, char **argv)
if (vm.count("test-lyrics-fetchers")) if (vm.count("test-lyrics-fetchers"))
{ {
std::vector<std::tuple<std::string, std::string, std::string>> fetcher_data = { std::vector<std::tuple<std::string, std::string, std::string>> fetcher_data = {
std::make_tuple("azlyrics", "rihanna", "umbrella"),
std::make_tuple("genius", "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("justsomelyrics", "rihanna", "umbrella"),
std::make_tuple("jahlyrics", "sean kingston", "dry your eyes"), 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("tekstowo", "rihanna", "umbrella"),
std::make_tuple("zeneszoveg", "rihanna", "umbrella"), std::make_tuple("zeneszoveg", "rihanna", "umbrella"),
}; };

View File

@@ -38,16 +38,8 @@ std::istream &operator>>(std::istream &is, LyricsFetcher_ &fetcher)
{ {
std::string s; std::string s;
is >> s; is >> s;
if (s == "azlyrics") if (s == "genius")
fetcher = std::make_unique<AzLyricsFetcher>();
else if (s == "genius")
fetcher = std::make_unique<GeniusFetcher>(); fetcher = std::make_unique<GeniusFetcher>();
else if (s == "musixmatch")
fetcher = std::make_unique<MusixmatchFetcher>();
else if (s == "sing365")
fetcher = std::make_unique<Sing365Fetcher>();
else if (s == "metrolyrics")
fetcher = std::make_unique<MetrolyricsFetcher>();
else if (s == "justsomelyrics") else if (s == "justsomelyrics")
fetcher = std::make_unique<JustSomeLyricsFetcher>(); fetcher = std::make_unique<JustSomeLyricsFetcher>();
else if (s == "jahlyrics") else if (s == "jahlyrics")
@@ -76,7 +68,7 @@ LyricsFetcher::Result LyricsFetcher::fetch(const std::string &artist,
std::string url = urlTemplate(); std::string url = urlTemplate();
boost::replace_all(url, "%artist%", Curl::escape(artist)); boost::replace_all(url, "%artist%", Curl::escape(artist));
boost::replace_all(url, "%title%", Curl::escape(title)); boost::replace_all(url, "%title%", Curl::escape(title));
std::string data; std::string data;
CURLcode code = Curl::perform(data, url, "", true); CURLcode code = Curl::perform(data, url, "", true);
@@ -88,9 +80,11 @@ LyricsFetcher::Result LyricsFetcher::fetch(const std::string &artist,
auto lyrics = getContent(regex(), data); auto lyrics = getContent(regex(), data);
//std::cerr << "URL: " << url << "\n";
//std::cerr << "Data: " << data << "\n";
if (lyrics.empty() || notLyrics(data)) if (lyrics.empty() || notLyrics(data))
{ {
//std::cerr << "Data: " << data << "\n";
//std::cerr << "Empty: " << lyrics.empty() << "\n"; //std::cerr << "Empty: " << lyrics.empty() << "\n";
//std::cerr << "Not Lyrics: " << notLyrics(data) << "\n"; //std::cerr << "Not Lyrics: " << notLyrics(data) << "\n";
result.second = msgNotFound; 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, LyricsFetcher::Result InternetLyricsFetcher::fetch(const std::string &artist,
const std::string &title) const std::string &title)
{ {

View File

@@ -69,34 +69,6 @@ private:
const char *URL; const char *URL;
}; };
struct MusixmatchFetcher : public GoogleLyricsFetcher
{
virtual const char *name() const override { return "musixmatch.com"; }
protected:
virtual const char *regex() const override { return "<span class=\"lyrics__content__.*?>(.*?)</span>"; }
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 "<div class=\"lyrics-body\">(.*?)<!--WIDGET.*?<!-- Second Section -->(.*?)<!--WIDGET.*?<!-- Third Section -->(.*?)</div>"; }
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 "<div class=\"lyrics\">(.*?)</div>"; }
};
struct JustSomeLyricsFetcher : public GoogleLyricsFetcher struct JustSomeLyricsFetcher : public GoogleLyricsFetcher
{ {
virtual const char *name() const override { return "justsomelyrics.com"; } virtual const char *name() const override { return "justsomelyrics.com"; }
@@ -105,14 +77,6 @@ protected:
virtual const char *regex() const override { return "<div class=\"content.*?</div>(.*?)See also"; } virtual const char *regex() const override { return "<div class=\"content.*?</div>(.*?)See also"; }
}; };
struct AzLyricsFetcher : public GoogleLyricsFetcher
{
virtual const char *name() const override { return "azlyrics.com"; }
protected:
virtual const char *regex() const override { return "<div class=\"lyricsh\">.*?</h2>.*<div>(.*?)</div>"; }
};
struct GeniusFetcher : public GoogleLyricsFetcher struct GeniusFetcher : public GoogleLyricsFetcher
{ {
virtual const char *name() const override { return "genius.com"; } 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"; } virtual const char *name() const override { return "tekstowo.pl"; }
protected: protected:
virtual const char *regex() const override { return "<div class=\"song-text\".*?>.*?</h2>(.*?)<a"; } virtual const char *regex() const override { return "<div class=\"inner-text\">(.*?)</div>"; }
}; };
struct ZeneszovegFetcher : public GoogleLyricsFetcher struct ZeneszovegFetcher : public GoogleLyricsFetcher
@@ -150,7 +114,7 @@ struct ZeneszovegFetcher : public GoogleLyricsFetcher
virtual const char *name() const override { return "zeneszoveg.hu"; } virtual const char *name() const override { return "zeneszoveg.hu"; }
protected: protected:
virtual const char *regex() const override { return "<div class=\"lyrics-plain-text.*?\">(.*?)</div>"; } virtual const char *regex() const override { return "<div id=\"tartalom_slide_content\"> (.*?)<style>"; }
}; };
struct InternetLyricsFetcher : public GoogleLyricsFetcher struct InternetLyricsFetcher : public GoogleLyricsFetcher

View File

@@ -459,7 +459,7 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
p.add("header_text_scrolling", &header_text_scrolling, "yes", yes_no); p.add("header_text_scrolling", &header_text_scrolling, "yes", yes_no);
p.add("cyclic_scrolling", &use_cyclic_scrolling, "no", yes_no); p.add("cyclic_scrolling", &use_cyclic_scrolling, "no", yes_no);
p.add("lyrics_fetchers", &lyrics_fetchers, p.add("lyrics_fetchers", &lyrics_fetchers,
"azlyrics, genius, musixmatch, sing365, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, zeneszoveg, internet", "genius, tekstowo, plyrics, justsomelyrics, jahlyrics, zeneszoveg, internet",
list_of<LyricsFetcher_>); list_of<LyricsFetcher_>);
p.add("follow_now_playing_lyrics", &now_playing_lyrics, "no", yes_no); 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, p.add("fetch_lyrics_for_current_song_in_background", &fetch_lyrics_in_background,