From 342521459c4de50396054a0224356c3044fa4043 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Fri, 13 Aug 2010 06:11:13 +0200 Subject: [PATCH] settings: add support for preferred last.fm info language --- doc/config | 10 ++++++++++ doc/ncmpcpp.1 | 3 +++ src/ncmpcpp.cpp | 2 +- src/settings.cpp | 5 +++++ src/settings.h | 1 + 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/config b/doc/config index 96643ca7..d52aea7b 100644 --- a/doc/config +++ b/doc/config @@ -287,6 +287,16 @@ # #follow_now_playing_lyrics = "no" # +## +## Note: If you set this variable, 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. +## +## Note: Language has to be expressed as an ISO 639 alpha-2 code. +## +#lastfm_preferred_language = "" +# #ncmpc_like_songs_adding = "no" (enabled - add/remove, disabled - always add) # #show_hidden_files_in_local_browser = "no" diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 5042b036..0105bca7 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -219,6 +219,9 @@ If enabled, seek time will increment by one each second of seeking. .B follow_now_playing_lyrics = yes/no If enabled, lyrics will be switched at song's change to currently playing one's (Note: this works only if you are viewing lyrics of item from Playlist). .TP +.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. +.TP .B ncmpc_like_songs_adding = yes/no If enabled, pressing space on item, which is already in playlist will remove it, otherwise add it again. .TP diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index e73c808d..8eba73c2 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -2068,7 +2068,7 @@ int main(int argc, char *argv[]) else if (myScreen == myLibrary && myLibrary->Main() == myLibrary->Artists) artist = myLibrary->Artists->Current(); - if (!artist.empty() && myLastfm->SetArtistInfoArgs(artist)) + if (!artist.empty() && myLastfm->SetArtistInfoArgs(artist, Config.lastfm_preferred_language)) myLastfm->SwitchTo(); } # endif // HAVE_CURL_CURL_H diff --git a/src/settings.cpp b/src/settings.cpp index a415a2d0..7c603431 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -763,6 +763,11 @@ void NcmpcppConfig::Read() new_header_second_line += '}'; } } + else if (cl.find("lastfm_preferred_language") != std::string::npos) + { + if (!v.empty() && v != "en") + lastfm_preferred_language = v; + } else if (cl.find("browser_playlist_prefix") != std::string::npos) { if (!v.empty()) diff --git a/src/settings.h b/src/settings.h index c370798f..ee565c57 100644 --- a/src/settings.h +++ b/src/settings.h @@ -166,6 +166,7 @@ struct NcmpcppConfig std::string execute_on_song_change; std::string new_header_first_line; std::string new_header_second_line; + std::string lastfm_preferred_language; std::basic_string progressbar; std::string pattern;