Make the list of lyrics fetchers customizable

This commit is contained in:
Andrzej Rybczak
2016-11-16 09:12:06 +01:00
parent b833818023
commit a2862b9fdf
9 changed files with 120 additions and 49 deletions

View File

@@ -25,6 +25,7 @@
#ifdef HAVE_CURL_CURL_H
#include <memory>
#include <string>
struct LyricsFetcher
@@ -46,6 +47,12 @@ protected:
static const char msgNotFound[];
};
typedef std::vector<std::unique_ptr<LyricsFetcher>> LyricsFetchers;
std::unique_ptr<LyricsFetcher> toLyricsFetcher(const std::string &s);
/**********************************************************************/
struct LyricwikiFetcher : public LyricsFetcher
{
virtual const char *name() const override { return "lyricwiki.com"; }
@@ -116,7 +123,7 @@ protected:
virtual const char *regex() const override { return "<div class=\"lyricsh\">.*?</h2>.*<div>(.*?)</div>"; }
};
struct GeniusLyricsFetcher : public GoogleLyricsFetcher
struct GeniusFetcher : public GoogleLyricsFetcher
{
virtual const char *name() const override { return "genius.com"; }
@@ -124,7 +131,7 @@ protected:
virtual const char *regex() const override { return "<lyrics.*?>(.*?)</lyrics>"; }
};
struct TekstowoLyricsFetcher : public GoogleLyricsFetcher
struct TekstowoFetcher : public GoogleLyricsFetcher
{
virtual const char *name() const override { return "tekstowo.pl"; }
@@ -147,8 +154,6 @@ private:
std::string URL;
};
extern LyricsFetcher *lyricsPlugins[];
#endif // HAVE_CURL_CURL_H
#endif // NCMPCPP_LYRICS_FETCHER_H