From 68a7d11c0e9d73383f89663748574ef6816e512d Mon Sep 17 00:00:00 2001
From: Andrzej Rybczak
Date: Wed, 11 Aug 2010 13:34:18 +0200
Subject: [PATCH] lyrics fetcher: add songlyrics.com and lyriczz.com support
---
src/lyrics_fetcher.cpp | 18 ++++++++++++++++++
src/lyrics_fetcher.h | 25 +++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/src/lyrics_fetcher.cpp b/src/lyrics_fetcher.cpp
index 40012642..d0c4200b 100644
--- a/src/lyrics_fetcher.cpp
+++ b/src/lyrics_fetcher.cpp
@@ -31,6 +31,8 @@
LyricsFetcher *lyricsPlugins[] =
{
new LyricwikiFetcher(),
+ new LyriczzFetcher(),
+ new SonglyricsFetcher(),
new LyricsmaniaFetcher(),
new LyricstimeFetcher(),
new MetrolyricsFetcher(),
@@ -183,6 +185,11 @@ LyricsFetcher::Result GoogleLyricsFetcher::fetch(const std::string &artist, cons
return LyricsFetcher::fetch("", "");
}
+bool GoogleLyricsFetcher::notLyrics(const std::string &data)
+{
+ return LyricsFetcher::notLyrics(data);
+}
+
bool GoogleLyricsFetcher::isURLOk(const std::string &url)
{
return url.find(getSiteKeyword()) != std::string::npos;
@@ -230,5 +237,16 @@ void LyricsmaniaFetcher::postProcess(std::string &data)
LyricsFetcher::postProcess(data);
}
+/**********************************************************************/
+
+void SonglyricsFetcher::postProcess(std::string &data)
+{
+ size_t i = data.find('['), j = data.find(']');
+ if (i != std::string::npos && i != std::string::npos)
+ data.replace(i, j-i+2, "");
+ data = unescapeHtmlUtf8(data);
+ LyricsFetcher::postProcess(data);
+}
+
#endif // HAVE_CURL_CURL_H
diff --git a/src/lyrics_fetcher.h b/src/lyrics_fetcher.h
index c45bcdc3..4e08cf99 100644
--- a/src/lyrics_fetcher.h
+++ b/src/lyrics_fetcher.h
@@ -94,6 +94,7 @@ struct GoogleLyricsFetcher : public LyricsFetcher
virtual const char *getSiteKeyword() = 0;
virtual const char *getURL() { return URL; }
+ virtual bool notLyrics(const std::string &data);
virtual bool isURLOk(const std::string &url);
private:
const char *URL;
@@ -139,6 +140,30 @@ struct LyricsmaniaFetcher : public GoogleLyricsFetcher
virtual void postProcess(std::string &data);
};
+struct SonglyricsFetcher : public GoogleLyricsFetcher
+{
+ virtual const char *name() { return "songlyrics.com"; }
+
+ protected:
+ virtual const char *getSiteKeyword() { return "songlyrics"; }
+ virtual const char *getOpenTag() { return "-6000px;\">"; }
+ virtual const char *getCloseTag() { return "
"; }
+
+ virtual void postProcess(std::string &data);
+};
+
+struct LyriczzFetcher : public GoogleLyricsFetcher
+{
+ virtual const char *name() { return "lyriczz.com"; }
+
+ protected:
+ virtual const char *getSiteKeyword() { return "lyriczz"; }
+ virtual const char *getOpenTag() { return "border=0 />"; }
+ virtual const char *getCloseTag() { return "