new feature: refetch lyrics

This commit is contained in:
Andrzej Rybczak
2009-10-20 00:35:51 +02:00
parent a98eb5e9ac
commit 62b7df69f3
4 changed files with 22 additions and 0 deletions

View File

@@ -276,6 +276,7 @@ void Help::GetKeybindings()
*w << "\n\n " << fmtBold << "Keys - Lyrics\n -----------------------------------------\n" << fmtBoldEnd;
*w << DisplayKeys(Key.Space) << "Switch for following lyrics of now playing song\n";
*w << DisplayKeys(Key.EditTags) << "Open lyrics in external editor\n";
*w << DisplayKeys(Key.SwitchTagTypeList) << "Refetch lyrics\n";
# ifdef HAVE_TAGLIB_H

View File

@@ -18,6 +18,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <cerrno>
#include <cstring>
#ifdef WIN32
# include <io.h>
@@ -300,6 +301,21 @@ void Lyrics::Edit()
system(("nohup " + Config.external_editor + " \"" + itsFilenamePath + "\" > /dev/null 2>&1 &").c_str());
}
void Lyrics::FetchAgain()
{
std::string path = Folder + "/" + locale_to_utf_cpy(itsSong.GetArtist()) + " - " + locale_to_utf_cpy(itsSong.GetTitle()) + ".txt";
if (!remove(path.c_str()))
{
myScreen = myOldScreen;
SwitchTo();
}
else
{
static const char msg[] = "Couldn't remove \"%s\": %s";
ShowMessage(msg, Shorten(TO_WSTRING(path), COLS-static_strlen(msg)-25).c_str(), strerror(errno));
}
}
#ifdef HAVE_CURL_CURL_H
#ifdef HAVE_PTHREAD_H

View File

@@ -58,6 +58,7 @@ class Lyrics : public Screen<Scrollpad>
virtual List *GetList() { return 0; }
void Edit();
void FetchAgain();
static bool Reload;

View File

@@ -1853,6 +1853,10 @@ int main(int argc, char *argv[])
ShowMessage("Switched to list of %s tag", item_type.c_str());
}
}
else if (myScreen == myLyrics)
{
myLyrics->FetchAgain();
}
}
else if (Keypressed(input, Key.SongInfo))
{