settings: new configuration variable: generate_win32_compatible_filenames
This commit is contained in:
@@ -345,6 +345,8 @@
|
|||||||
#
|
#
|
||||||
#store_lyrics_in_song_dir = "no"
|
#store_lyrics_in_song_dir = "no"
|
||||||
#
|
#
|
||||||
|
#generate_win32_compatible_filenames = "yes"
|
||||||
|
#
|
||||||
##
|
##
|
||||||
## Note: If you set this variable, ncmpcpp will try to
|
## Note: If you set this variable, ncmpcpp will try to
|
||||||
## get info from last.fm in language you set and if it
|
## get info from last.fm in language you set and if it
|
||||||
|
|||||||
@@ -258,6 +258,9 @@ If enabled, each time song changes lyrics fetcher will be automatically run in b
|
|||||||
.B store_lyrics_in_song_dir = yes/no
|
.B store_lyrics_in_song_dir = yes/no
|
||||||
If enabled, lyrics will be saved in song's directory, otherwise in ~/.lyrics. Note that it needs properly set mpd_music_dir.
|
If enabled, lyrics will be saved in song's directory, otherwise in ~/.lyrics. Note that it needs properly set mpd_music_dir.
|
||||||
.TP
|
.TP
|
||||||
|
.B generate_win32_compatible_filenames = yes/no
|
||||||
|
If set to yes, filenames generated by ncmpcpp (with tag editor, for lyrics, artists etc.) will not contain the following characters: /\?*:|"<> - otherwise only slash (/) will not be used.
|
||||||
|
.TP
|
||||||
.B lastfm_preferred_language = ISO 639 alpha-2 language code
|
.B lastfm_preferred_language = ISO 639 alpha-2 language code
|
||||||
If set, ncmpcpp will try to get info from last.fm in language you set and if it fails, it will fall back to english. Otherwise it will use english the first time.
|
If set, ncmpcpp will try to get info from last.fm in language you set and if it fails, it will fall back to english. Otherwise it will use english the first time.
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ void Lastfm::Load()
|
|||||||
|
|
||||||
std::string artist = itsArgs.find("artist")->second;
|
std::string artist = itsArgs.find("artist")->second;
|
||||||
std::string file = boost::locale::to_lower(artist + ".txt");
|
std::string file = boost::locale::to_lower(artist + ".txt");
|
||||||
removeInvalidCharsFromFilename(file);
|
removeInvalidCharsFromFilename(file, Config.generate_win32_compatible_filenames);
|
||||||
|
|
||||||
itsFilename = itsFolder + "/" + file;
|
itsFilename = itsFolder + "/" + file;
|
||||||
|
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ std::string Lyrics::GenerateFilename(const MPD::Song &s)
|
|||||||
file += " - ";
|
file += " - ";
|
||||||
file += s.getTitle();
|
file += s.getTitle();
|
||||||
file += ".txt";
|
file += ".txt";
|
||||||
removeInvalidCharsFromFilename(file);
|
removeInvalidCharsFromFilename(file, Config.generate_win32_compatible_filenames);
|
||||||
filename = Config.lyrics_directory;
|
filename = Config.lyrics_directory;
|
||||||
filename += "/";
|
filename += "/";
|
||||||
filename += file;
|
filename += file;
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ void Configuration::SetDefaults()
|
|||||||
tag_editor_extended_numeration = false;
|
tag_editor_extended_numeration = false;
|
||||||
discard_colors_if_item_is_selected = true;
|
discard_colors_if_item_is_selected = true;
|
||||||
store_lyrics_in_song_dir = false;
|
store_lyrics_in_song_dir = false;
|
||||||
|
generate_win32_compatible_filenames = true;
|
||||||
ask_for_locked_screen_width_part = true;
|
ask_for_locked_screen_width_part = true;
|
||||||
progressbar_boldness = true;
|
progressbar_boldness = true;
|
||||||
set_window_title = true;
|
set_window_title = true;
|
||||||
@@ -764,6 +765,10 @@ void Configuration::Read()
|
|||||||
else
|
else
|
||||||
store_lyrics_in_song_dir = v == "yes";
|
store_lyrics_in_song_dir = v == "yes";
|
||||||
}
|
}
|
||||||
|
else if (name == "generate_win32_compatible_filenames")
|
||||||
|
{
|
||||||
|
generate_win32_compatible_filenames = v == "yes";
|
||||||
|
}
|
||||||
else if (name == "enable_window_title")
|
else if (name == "enable_window_title")
|
||||||
{
|
{
|
||||||
set_window_title = v == "yes";
|
set_window_title = v == "yes";
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ struct Configuration
|
|||||||
bool tag_editor_extended_numeration;
|
bool tag_editor_extended_numeration;
|
||||||
bool discard_colors_if_item_is_selected;
|
bool discard_colors_if_item_is_selected;
|
||||||
bool store_lyrics_in_song_dir;
|
bool store_lyrics_in_song_dir;
|
||||||
|
bool generate_win32_compatible_filenames;
|
||||||
bool ask_for_locked_screen_width_part;
|
bool ask_for_locked_screen_width_part;
|
||||||
bool progressbar_boldness;
|
bool progressbar_boldness;
|
||||||
|
|
||||||
|
|||||||
@@ -1099,7 +1099,7 @@ MPD::MutableSong::SetFunction IntoSetFunction(char c)
|
|||||||
std::string GenerateFilename(const MPD::MutableSong &s, const std::string &pattern)
|
std::string GenerateFilename(const MPD::MutableSong &s, const std::string &pattern)
|
||||||
{
|
{
|
||||||
std::string result = s.toString(pattern, Config.tags_separator);
|
std::string result = s.toString(pattern, Config.tags_separator);
|
||||||
removeInvalidCharsFromFilename(result);
|
removeInvalidCharsFromFilename(result, Config.generate_win32_compatible_filenames);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ std::string getEnclosedString(const std::string &s, char a, char b, size_t *pos)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeInvalidCharsFromFilename(std::string &filename)
|
void removeInvalidCharsFromFilename(std::string &filename, bool win32_compatible)
|
||||||
{
|
{
|
||||||
const char *unallowed_chars = "\"*/:<>?\\|";
|
const char *unallowed_chars = win32_compatible ? "\"*/:<>?\\|" : "/";
|
||||||
for (const char *c = unallowed_chars; *c; ++c)
|
for (const char *c = unallowed_chars; *c; ++c)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < filename.length(); ++i)
|
for (size_t i = 0; i < filename.length(); ++i)
|
||||||
|
|||||||
@@ -39,6 +39,6 @@ std::string getSharedDirectory(const std::string &dir1, const std::string &dir2)
|
|||||||
|
|
||||||
std::string getEnclosedString(const std::string &s, char a, char b, size_t *pos);
|
std::string getEnclosedString(const std::string &s, char a, char b, size_t *pos);
|
||||||
|
|
||||||
void removeInvalidCharsFromFilename(std::string &filename);
|
void removeInvalidCharsFromFilename(std::string &filename, bool win32_compatible);
|
||||||
|
|
||||||
#endif // NCMPCPP_UTILITY_STRING_H
|
#endif // NCMPCPP_UTILITY_STRING_H
|
||||||
|
|||||||
Reference in New Issue
Block a user