From 27ede67685dce2ba3e0fa26cd0ac63e0bb7eae32 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 5 Aug 2009 14:35:45 +0200 Subject: [PATCH] remove lyricswiki support as it doesn't allow fetching lyrics anymore --- doc/config | 3 +-- doc/ncmpcpp.1 | 3 +-- src/lyrics.cpp | 32 +++++++++----------------------- src/lyrics.h | 4 ++-- src/settings.cpp | 6 +++++- 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/doc/config b/doc/config index 8c434ce8..41162025 100644 --- a/doc/config +++ b/doc/config @@ -200,8 +200,7 @@ ## ## supported lyrics databases: ## -## - 1 - lyricwiki.org -## - 2 - lyricsplugin.com +## - 1 - lyricsplugin.com ## # #lyrics_database = "1" diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 4cde59ec..fd9186fa 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -206,8 +206,7 @@ Type of currently used regular expressions. .TP .B lyrics_database = NUMBER Number of lyrics database in use. Currently supported DBs are: - 1 - lyricwiki.org - 2 - lyricsplugin.com + 1 - lyricsplugin.com .TP .B media_library_left_column = a/y/g/c/p Default tag type for left column in media library. Legend for possible letters is in SONG FORMAT section. diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 015dbf4e..f72466ca 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -313,16 +313,19 @@ void Lyrics::Take() } #endif // HAVE_PTHREAD_H +const unsigned Lyrics::DBs = 1; // number of currently supported lyrics databases + +const char *Lyrics::PluginsList[] = +{ + "lyricsplugin.com", + 0 +}; + const char *Lyrics::GetPluginName(int offset) { return PluginsList[offset]; } -bool Lyrics::LyricWiki_NotFound(const std::string &s) -{ - return s == "Not found"; -} - bool Lyrics::LyricsPlugin_NotFound(const std::string &s) { if (s.empty()) @@ -333,14 +336,6 @@ bool Lyrics::LyricsPlugin_NotFound(const std::string &s) return true; } -const Lyrics::Plugin Lyrics::LyricWiki = -{ - "http://lyricwiki.org/api.php?artist=%artist%&song=%title%&fmt=xml", - "", - "", - LyricWiki_NotFound -}; - const Lyrics::Plugin Lyrics::LyricsPlugin = { "http://www.lyricsplugin.com/winamp03/plugin/?artist=%artist%&title=%title%", @@ -349,23 +344,14 @@ const Lyrics::Plugin Lyrics::LyricsPlugin = LyricsPlugin_NotFound }; -const char *Lyrics::PluginsList[] = -{ - "lyricwiki.org", - "lyricsplugin.com", - 0 -}; - const Lyrics::Plugin *Lyrics::ChoosePlugin(int i) { switch (i) { case 0: - return &LyricWiki; - case 1: return &LyricsPlugin; default: - return &LyricWiki; + return &LyricsPlugin; } } diff --git a/src/lyrics.h b/src/lyrics.h index 781432a7..8ce19148 100644 --- a/src/lyrics.h +++ b/src/lyrics.h @@ -63,6 +63,8 @@ class Lyrics : public Screen # ifdef HAVE_CURL_CURL_H static const char *GetPluginName(int offset); + + static const unsigned DBs; # endif // HAVE_CURL_CURL_H protected: @@ -81,7 +83,6 @@ class Lyrics : public Screen # endif // HAVE_PTHREAD_H static const Plugin *ChoosePlugin(int); - static bool LyricWiki_NotFound(const std::string &); static bool LyricsPlugin_NotFound(const std::string &); static bool Ready; @@ -91,7 +92,6 @@ class Lyrics : public Screen # endif // HAVE_PTHREAD_H static const char *PluginsList[]; - static const Plugin LyricWiki; static const Plugin LyricsPlugin; # endif // HAVE_CURL_CURL_H diff --git a/src/settings.cpp b/src/settings.cpp index c43e4524..b4a378fa 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -26,6 +26,7 @@ #include #include "helpers.h" +#include "lyrics.h" #include "settings.h" const std::string config_file = config_dir + "config"; @@ -702,7 +703,10 @@ void ReadConfiguration(ncmpcpp_config &conf) else if (cl.find("lyrics_database") != std::string::npos) { if (!v.empty()) - conf.lyrics_db = StrToInt(v)-1; + { + unsigned n = StrToInt(v)-1; + conf.lyrics_db = n < Lyrics::DBs ? n : 0; + } } else if (cl.find("song_window_title_format") != std::string::npos) {