summaryrefslogtreecommitdiff
path: root/src/lyrics.cpp
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2010-08-10 20:39:08 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2010-08-10 20:39:08 +0200
commite1b1cf838ae0860ce39a1901e8c3c1ad1f081a95 (patch)
treef8105d03e490d80268f7b33a12af6d174bc2da9a /src/lyrics.cpp
parent73339eed9c6a536cb35dc18816484f2213f93208 (diff)
lyrics: restore database selector
Diffstat (limited to 'src/lyrics.cpp')
-rw-r--r--src/lyrics.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/lyrics.cpp b/src/lyrics.cpp
index 20af43eb..a19d51ff 100644
--- a/src/lyrics.cpp
+++ b/src/lyrics.cpp
@@ -33,7 +33,6 @@
#include "global.h"
#include "helpers.h"
#include "lyrics.h"
-#include "lyrics_fetcher.h"
#include "playlist.h"
#include "settings.h"
#include "song.h"
@@ -145,7 +144,10 @@ void *Lyrics::Download()
LyricsFetcher::Result result;
- for (LyricsFetcher **plugin = lyricsPlugins; *plugin != 0; ++plugin)
+ // if one of plugins is selected, try only this one,
+ // otherwise try all of them until one of them succeeds
+ bool fetcher_defined = Fetcher && *Fetcher;
+ for (LyricsFetcher **plugin = fetcher_defined ? Fetcher : lyricsPlugins; *plugin != 0; ++plugin)
{
*w << "Fetching lyrics from " << fmtBold << (*plugin)->name() << fmtBoldEnd << "... ";
result = (*plugin)->fetch(artist, title);
@@ -153,6 +155,8 @@ void *Lyrics::Download()
*w << clRed << result.second << clEnd << "\n";
else
break;
+ if (fetcher_defined)
+ break;
}
if (result.first == true)
@@ -261,7 +265,10 @@ void Lyrics::Save(const std::string &lyrics)
void Lyrics::Refetch()
{
- std::string path = Folder + "/" + locale_to_utf_cpy(itsSong.GetArtist()) + " - " + locale_to_utf_cpy(itsSong.GetTitle()) + ".txt";
+ std::string file = locale_to_utf_cpy(itsSong.GetArtist()) + " - " + locale_to_utf_cpy(itsSong.GetTitle()) + ".txt";
+ EscapeUnallowedChars(file);
+ std::string path = Folder + "/" + file;
+
if (!remove(path.c_str()))
{
Load();
@@ -274,6 +281,18 @@ void Lyrics::Refetch()
}
#ifdef HAVE_CURL_CURL_H
+void Lyrics::ToggleFetcher()
+{
+ if (Fetcher && *Fetcher)
+ ++Fetcher;
+ else
+ Fetcher = &lyricsPlugins[0];
+ if (*Fetcher)
+ ShowMessage("Using lyrics database: %s", (*Fetcher)->name());
+ else
+ ShowMessage("Using all lyrics databases");
+}
+
void Lyrics::Take()
{
assert(ReadyToTake);