Add test for checking whether lyrics fetchers work

This commit is contained in:
Andrzej Rybczak
2017-01-28 18:24:03 +01:00
parent 0b1f0bfe0d
commit 8b014bd970
2 changed files with 31 additions and 0 deletions

1
NEWS
View File

@@ -21,6 +21,7 @@ ncmpcpp-0.8 (????-??-??)
* Fixed an issue that could cause some MPD events to be missed.
* Action 'jump_to_playing_song' is not runnable now if there is no playing song.
* Fixed fetching artist info in language other than English.
* Added test that checks if lyrics fetchers work (available via command line parameter --test-lyrics-fetchers).
ncmpcpp-0.7.7 (2016-10-31)
* Fixed compilation on 32bit platforms.

View File

@@ -22,6 +22,7 @@
#include <boost/algorithm/string/trim.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/program_options.hpp>
#include <iomanip>
#include <iostream>
#include "bindings.h"
@@ -81,6 +82,7 @@ bool configure(int argc, char **argv)
("current-song", po::value<std::string>()->implicit_value("{{{(%l) }{{%a - }%t}}|{%f}}"), "print current song using given format and exit")
("config,c", po::value<std::vector<std::string>>(&config_paths)->default_value(default_config_paths, join<std::string>(default_config_paths, " AND ")), "specify configuration file(s)")
("ignore-config-errors", "ignore unknown and invalid options in configuration files")
("test-lyrics-fetchers", "check if lyrics fetchers work")
("bindings,b", po::value<std::string>(&bindings_path)->default_value("~/.ncmpcpp/bindings"), "specify bindings file")
("screen,s", po::value<std::string>(), "specify the startup screen")
("slave-screen,S", po::value<std::string>(), "specify the startup slave screen")
@@ -134,6 +136,34 @@ bool configure(int argc, char **argv)
}
po::notify(vm);
if (vm.count("test-lyrics-fetchers"))
{
std::vector<std::string> fetcher_names = {
"lyricwiki",
"azlyrics",
"genius",
"sing365",
"lyricsmania",
"metrolyrics",
"justsomelyrics",
"tekstowo",
};
for (auto &name : fetcher_names)
{
auto fetcher = boost::lexical_cast<LyricsFetcher_>(name);
std::cout << std::setw(20)
<< std::left
<< fetcher->name()
<< " : "
<< std::flush;
auto result = fetcher->fetch("rihanna", "umbrella");
std::cout << (result.first ? "ok" : "failed")
<< "\n";
}
exit(0);
}
// get home directory
env_home = getenv("HOME");
if (env_home == nullptr)