lyrics fetcher: add sing365.com db support + a few corrections

This commit is contained in:
Andrzej Rybczak
2010-08-11 16:44:51 +02:00
parent 2a79184108
commit d4a5574146
2 changed files with 18 additions and 10 deletions

View File

@@ -31,6 +31,7 @@
LyricsFetcher *lyricsPlugins[] =
{
new LyricwikiFetcher(),
new Sing365Fetcher(),
new LyriczzFetcher(),
new SonglyricsFetcher(),
new LyricsmaniaFetcher(),
@@ -181,15 +182,14 @@ LyricsFetcher::Result GoogleLyricsFetcher::fetch(const std::string &artist, cons
return result;
}
data = unescapeHtmlUtf8(data);
//result.second = data;
//return result;
URL = data.c_str();
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;
@@ -224,7 +224,7 @@ void MetrolyricsFetcher::postProcess(std::string &data)
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.xml") == std::string::npos;
return GoogleLyricsFetcher::isURLOk(url) && url.find("sitemap") == std::string::npos;
}
/**********************************************************************/

View File

@@ -41,7 +41,7 @@ struct LyricsFetcher
virtual const char *getOpenTag() = 0;
virtual const char *getCloseTag() = 0;
virtual bool notLyrics(GNUC_UNUSED const std::string &data) { return false; }
virtual bool notLyrics(const std::string &) { return false; }
virtual void postProcess(std::string &data);
bool getContent(const char *open_tag, const char *close_tag, std::string &data);
@@ -94,8 +94,8 @@ 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;
};
@@ -160,8 +160,16 @@ struct LyriczzFetcher : public GoogleLyricsFetcher
virtual const char *getSiteKeyword() { return "lyriczz"; }
virtual const char *getOpenTag() { return "border=0 /></a>"; }
virtual const char *getCloseTag() { return "<a href"; }
//virtual void postProcess(std::string &data);
};
struct Sing365Fetcher : public GoogleLyricsFetcher
{
virtual const char *name() { return "sing365.com"; }
protected:
virtual const char *getSiteKeyword() { return "sing365"; }
virtual const char *getOpenTag() { return "<br><br></div>"; }
virtual const char *getCloseTag() { return "<div align"; }
};
extern LyricsFetcher *lyricsPlugins[];