From 8b109d07366829550e02d43df14e8552b75c2af9 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 8 Aug 2010 19:12:51 +0200 Subject: [PATCH] lyrics: add support for lyricsfly.com database --- doc/config | 1 + src/lyrics.cpp | 19 ++++++++++++++++--- src/lyrics.h | 3 ++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/doc/config b/doc/config index a8edceff..6970df08 100644 --- a/doc/config +++ b/doc/config @@ -389,6 +389,7 @@ ## supported lyrics databases: ## ## - 1 - lyrc.com.ar +## - 2 - lyricsfly.com ## # #lyrics_database = "1" diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 11c86f13..eacc20f0 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -261,6 +261,8 @@ void *Lyrics::Get(void *screen_void_ptr) pthread_exit(0); } + if (my_lyrics == &Lyricsfly) + Replace(result, "[br]", ""); Replace(result, "<", "<"); Replace(result, ">", ">"); @@ -337,12 +339,13 @@ void Lyrics::Take() } #endif // HAVE_PTHREAD_H -const unsigned Lyrics::DBs = 1; // number of currently supported lyrics databases +const unsigned Lyrics::DBs = 2; // number of currently supported lyrics databases const char *Lyrics::PluginsList[] = { //"lyricsplugin.com", "lyrc.com.ar", + "lyricsfly.com", 0 }; @@ -369,7 +372,7 @@ const Lyrics::Plugin Lyrics::LyricsPlugin = LyricsPlugin_NotFound };*/ -bool Lyrics::LyrcComAr_NotFound(const std::string &s) +bool Lyrics::Generic_NotFound(const std::string &s) { // it should never fail as open_tag and close_tag // are not present if lyrics are not found @@ -381,7 +384,15 @@ const Lyrics::Plugin Lyrics::LyrcComAr = "http://lyrc.com.ar/tema1es.php?artist=%artist%&songname=%title%", "", "

", - LyrcComAr_NotFound + Generic_NotFound +}; + +const Lyrics::Plugin Lyrics::Lyricsfly = +{ + "http://api.lyricsfly.com/api/api.php?i=30002e18b71fbe4f0-temporary.API.access&a=%artist%&t=%title%", + "", + "", + Generic_NotFound }; const Lyrics::Plugin *Lyrics::ChoosePlugin(int i) @@ -391,6 +402,8 @@ const Lyrics::Plugin *Lyrics::ChoosePlugin(int i) case 0: //return &LyricsPlugin; return &LyrcComAr; + case 1: + return &Lyricsfly; default: return &LyrcComAr; } diff --git a/src/lyrics.h b/src/lyrics.h index b9879b2c..360540b5 100644 --- a/src/lyrics.h +++ b/src/lyrics.h @@ -85,7 +85,7 @@ class Lyrics : public Screen static const Plugin *ChoosePlugin(int); //static bool LyricsPlugin_NotFound(const std::string &); - static bool LyrcComAr_NotFound(const std::string &); + static bool Generic_NotFound(const std::string &); static bool Ready; @@ -96,6 +96,7 @@ class Lyrics : public Screen static const char *PluginsList[]; //static const Plugin LyricsPlugin; static const Plugin LyrcComAr; + static const Plugin Lyricsfly; # endif // HAVE_CURL_CURL_H size_t itsScrollBegin;