Add support for fetching lyrics in background for selected songs
This commit is contained in:
1
NEWS
1
NEWS
@@ -10,6 +10,7 @@ ncmpcpp-0.8 (????-??-??)
|
|||||||
* Lyrics can now be fetched for songs with no tags.
|
* Lyrics can now be fetched for songs with no tags.
|
||||||
* libcurl dependency is no longer optional.
|
* libcurl dependency is no longer optional.
|
||||||
* When an attempt to write tags fails, show detailed error message.
|
* When an attempt to write tags fails, show detailed error message.
|
||||||
|
* Support for fetching lyrics for selected items in background was added.
|
||||||
|
|
||||||
ncmpcpp-0.7.7 (2016-10-31)
|
ncmpcpp-0.7.7 (2016-10-31)
|
||||||
* Fixed compilation on 32bit platforms.
|
* Fixed compilation on 32bit platforms.
|
||||||
|
|||||||
@@ -520,6 +520,9 @@
|
|||||||
# toggle_lyrics_fetcher
|
# toggle_lyrics_fetcher
|
||||||
#
|
#
|
||||||
#def_key "F"
|
#def_key "F"
|
||||||
|
# fetch_lyrics_in_background
|
||||||
|
#
|
||||||
|
#def_key "alt-l"
|
||||||
# toggle_fetching_lyrics_in_background
|
# toggle_fetching_lyrics_in_background
|
||||||
#
|
#
|
||||||
#def_key "ctrl-l"
|
#def_key "ctrl-l"
|
||||||
|
|||||||
@@ -2273,6 +2273,20 @@ void ToggleMediaLibrarySortMode::run()
|
|||||||
myLibrary->toggleSortMode();
|
myLibrary->toggleSortMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FetchLyricsInBackground::canBeRun()
|
||||||
|
{
|
||||||
|
m_hs = dynamic_cast<HasSongs *>(myScreen);
|
||||||
|
return m_hs != nullptr && m_hs->itemAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FetchLyricsInBackground::run()
|
||||||
|
{
|
||||||
|
auto songs = m_hs->getSelectedSongs();
|
||||||
|
for (const auto &s : songs)
|
||||||
|
myLyrics->fetchInBackground(s, true);
|
||||||
|
Statusbar::print("Selected songs queued for lyrics fetching");
|
||||||
|
}
|
||||||
|
|
||||||
bool RefetchLyrics::canBeRun()
|
bool RefetchLyrics::canBeRun()
|
||||||
{
|
{
|
||||||
return myScreen == myLyrics;
|
return myScreen == myLyrics;
|
||||||
@@ -2785,6 +2799,7 @@ void populateActions()
|
|||||||
insert_action(new Actions::ToggleBrowserSortMode());
|
insert_action(new Actions::ToggleBrowserSortMode());
|
||||||
insert_action(new Actions::ToggleLibraryTagType());
|
insert_action(new Actions::ToggleLibraryTagType());
|
||||||
insert_action(new Actions::ToggleMediaLibrarySortMode());
|
insert_action(new Actions::ToggleMediaLibrarySortMode());
|
||||||
|
insert_action(new Actions::FetchLyricsInBackground());
|
||||||
insert_action(new Actions::RefetchLyrics());
|
insert_action(new Actions::RefetchLyrics());
|
||||||
insert_action(new Actions::SetSelectedItemsPriority());
|
insert_action(new Actions::SetSelectedItemsPriority());
|
||||||
insert_action(new Actions::ToggleOutput());
|
insert_action(new Actions::ToggleOutput());
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ enum class Type
|
|||||||
ToggleBrowserSortMode,
|
ToggleBrowserSortMode,
|
||||||
ToggleLibraryTagType,
|
ToggleLibraryTagType,
|
||||||
ToggleMediaLibrarySortMode,
|
ToggleMediaLibrarySortMode,
|
||||||
|
FetchLyricsInBackground,
|
||||||
RefetchLyrics,
|
RefetchLyrics,
|
||||||
SetSelectedItemsPriority,
|
SetSelectedItemsPriority,
|
||||||
ToggleOutput,
|
ToggleOutput,
|
||||||
@@ -1163,6 +1164,18 @@ private:
|
|||||||
virtual void run() override;
|
virtual void run() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FetchLyricsInBackground: BaseAction
|
||||||
|
{
|
||||||
|
FetchLyricsInBackground()
|
||||||
|
: BaseAction(Type::FetchLyricsInBackground, "fetch_lyrics_in_background") { }
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual bool canBeRun() override;
|
||||||
|
virtual void run() override;
|
||||||
|
|
||||||
|
HasSongs *m_hs;
|
||||||
|
};
|
||||||
|
|
||||||
struct RefetchLyrics: BaseAction
|
struct RefetchLyrics: BaseAction
|
||||||
{
|
{
|
||||||
RefetchLyrics(): BaseAction(Type::RefetchLyrics, "refetch_lyrics") { }
|
RefetchLyrics(): BaseAction(Type::RefetchLyrics, "refetch_lyrics") { }
|
||||||
|
|||||||
@@ -721,6 +721,8 @@ void BindingsConfiguration::generateDefaults()
|
|||||||
if (notBound(k = stringToKey("L")))
|
if (notBound(k = stringToKey("L")))
|
||||||
bind(k, Actions::Type::ToggleLyricsFetcher);
|
bind(k, Actions::Type::ToggleLyricsFetcher);
|
||||||
if (notBound(k = stringToKey("F")))
|
if (notBound(k = stringToKey("F")))
|
||||||
|
bind(k, Actions::Type::FetchLyricsInBackground);
|
||||||
|
if (notBound(k = stringToKey("alt-l")))
|
||||||
bind(k, Actions::Type::ToggleFetchingLyricsInBackground);
|
bind(k, Actions::Type::ToggleFetchingLyricsInBackground);
|
||||||
if (notBound(k = stringToKey("ctrl-l")))
|
if (notBound(k = stringToKey("ctrl-l")))
|
||||||
bind(k, Actions::Type::ToggleScreenLock);
|
bind(k, Actions::Type::ToggleScreenLock);
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ void write_bindings(NC::Scrollpad &w)
|
|||||||
key(w, Type::JumpToPositionInSong, "Jump to given position in playing song (formats: mm:ss, x%)");
|
key(w, Type::JumpToPositionInSong, "Jump to given position in playing song (formats: mm:ss, x%)");
|
||||||
key(w, Type::ShowSongInfo, "Show song info");
|
key(w, Type::ShowSongInfo, "Show song info");
|
||||||
key(w, Type::ShowArtistInfo, "Show artist info");
|
key(w, Type::ShowArtistInfo, "Show artist info");
|
||||||
|
key(w, Type::FetchLyricsInBackground, "Fetch lyrics for selected songs");
|
||||||
key(w, Type::ToggleLyricsFetcher, "Toggle lyrics fetcher");
|
key(w, Type::ToggleLyricsFetcher, "Toggle lyrics fetcher");
|
||||||
key(w, Type::ToggleFetchingLyricsInBackground, "Toggle fetching lyrics for playing songs in background");
|
key(w, Type::ToggleFetchingLyricsInBackground, "Toggle fetching lyrics for playing songs in background");
|
||||||
key(w, Type::ShowLyrics, "Show/hide song lyrics");
|
key(w, Type::ShowLyrics, "Show/hide song lyrics");
|
||||||
|
|||||||
Reference in New Issue
Block a user