store fetched artist's info in ~/.ncmpcpp/artists instead of ~/.lyrics
This commit is contained in:
@@ -162,6 +162,22 @@ void WindowTitle(const string &status)
|
||||
printf("\033]0;%s\7",status.c_str());
|
||||
}
|
||||
|
||||
void EscapeUnallowedChars(string &s)
|
||||
{
|
||||
const string unallowed_chars = "\"*/:<>?\\|";
|
||||
for (string::const_iterator it = unallowed_chars.begin(); it != unallowed_chars.end(); it++)
|
||||
{
|
||||
for (int i = 0; i < s.length(); i++)
|
||||
{
|
||||
if (s[i] == *it)
|
||||
{
|
||||
s.erase(s.begin()+i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string FindSharedDir(const string &one, const string &two)
|
||||
{
|
||||
if (one == two)
|
||||
|
||||
@@ -46,6 +46,7 @@ void UpdateSongList(Menu<Song> *);
|
||||
bool Keypressed(int, const int *);
|
||||
|
||||
void WindowTitle(const string &);
|
||||
void EscapeUnallowedChars(string &);
|
||||
|
||||
string FindSharedDir(const string &, const string &);
|
||||
string TotalPlaylistLength();
|
||||
|
||||
@@ -19,12 +19,14 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include "helpers.h"
|
||||
#include "lyrics.h"
|
||||
#include "settings.h"
|
||||
#include "song.h"
|
||||
|
||||
extern ncmpcpp_config Config;
|
||||
|
||||
const string artists_folder = home_folder + "/" + ".ncmpcpp/artists";
|
||||
const string lyrics_folder = home_folder + "/" + ".lyrics";
|
||||
|
||||
#ifdef HAVE_CURL_CURL_H
|
||||
@@ -68,9 +70,12 @@ void * GetArtistInfo(void *ptr)
|
||||
string artist = *strptr;
|
||||
delete strptr;
|
||||
|
||||
const string filename = artist + ".txt";
|
||||
const string fullpath = lyrics_folder + "/" + filename;
|
||||
mkdir(lyrics_folder.c_str(), 0755);
|
||||
string filename = artist + ".txt";
|
||||
transform(filename.begin(), filename.end(), filename.begin(), tolower);
|
||||
EscapeUnallowedChars(filename);
|
||||
|
||||
const string fullpath = artists_folder + "/" + filename;
|
||||
mkdir(artists_folder.c_str(), 0755);
|
||||
|
||||
string *result = new string();
|
||||
std::ifstream input(fullpath.c_str());
|
||||
|
||||
@@ -139,6 +139,7 @@ const string message_part_of_songs_added = "Only part of requested songs' list a
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CreateConfigDir();
|
||||
DefaultConfiguration(Config);
|
||||
DefaultKeys(Key);
|
||||
ReadConfiguration(Config);
|
||||
|
||||
@@ -18,13 +18,19 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include "settings.h"
|
||||
|
||||
const string config_file = home_folder + "/.ncmpcpp/config";
|
||||
const string keys_config_file = home_folder + "/.ncmpcpp/keys";
|
||||
const string config_file = config_dir + "config";
|
||||
const string keys_config_file = config_dir + "keys";
|
||||
|
||||
using std::ifstream;
|
||||
|
||||
void CreateConfigDir()
|
||||
{
|
||||
mkdir(config_dir.c_str(), 0755);
|
||||
}
|
||||
|
||||
void DefaultKeys(ncmpcpp_keys &keys)
|
||||
{
|
||||
keys.Up[0] = KEY_UP;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "ncmpcpp.h"
|
||||
|
||||
const string config_dir = home_folder + "/.ncmpcpp/";
|
||||
const int null_key = 0x0fffffff;
|
||||
|
||||
struct ncmpcpp_keys
|
||||
@@ -146,6 +147,7 @@ struct ncmpcpp_config
|
||||
int message_delay_time;
|
||||
};
|
||||
|
||||
void CreateConfigDir();
|
||||
void DefaultKeys(ncmpcpp_keys &);
|
||||
void DefaultConfiguration(ncmpcpp_config &);
|
||||
void ReadKeys(ncmpcpp_keys &);
|
||||
|
||||
@@ -222,16 +222,8 @@ namespace
|
||||
|
||||
string GenerateFilename(const Song &s, string &pattern)
|
||||
{
|
||||
const string unallowed_chars = "\"*/:<>?\\|";
|
||||
string result = Window::OmitBBCodes(DisplaySong(s, &pattern));
|
||||
for (string::const_iterator it = unallowed_chars.begin(); it != unallowed_chars.end(); it++)
|
||||
{
|
||||
for (int i = 0; i < result.length(); i++)
|
||||
{
|
||||
if (result[i] == *it)
|
||||
result.erase(result.begin()+i);
|
||||
}
|
||||
}
|
||||
EscapeUnallowedChars(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user