Use thetvdb name of show in '%show'

This commit is contained in:
zvon 2019-01-26 00:50:26 +01:00
parent 4c8922b619
commit 3d4c355342
4 changed files with 16 additions and 15 deletions

View File

@ -148,20 +148,20 @@ void findSeasons(std::map<int, std::set<std::string>> &seasons, const std::strin
}
}
std::string getDefUrl( std::string show, const std::string &language, Curl &c ) {
std::string getDefUrl( std::string &show, const std::string &language, Curl &c ) {
std::replace(show.begin(), show.end(), ' ', '+');
auto source_code = c.execute("https://www.thetvdb.com/search?q=" + encodeUrl(show) + "&l=" + language);
size_t order{}, pos{};
std::vector<std::string> urls;
std::vector<std::pair<std::string, std::string>> urls;
while( true ) {
pos = source_code.find("/ser", pos);
if( pos != std::string::npos ) {
auto end = source_code.find(">", pos);
end--;
urls.push_back(source_code.substr(pos, end - pos));
pos = end + 2;
end = source_code.find("<", pos);
std::cout << ++order << ". " << source_code.substr(pos, end - pos) << std::endl;
auto end2 = source_code.find("<", end + 2);
urls.emplace_back(source_code.substr(end + 2, end2 - end - 2), source_code.substr(pos, end - pos));
std::cout << ++order << ". " << urls.back().first << std::endl;
pos = end2;
} else {
break;
}
@ -170,7 +170,8 @@ std::string getDefUrl( std::string show, const std::string &language, Curl &c )
std::cin >> pos;
std::cin.clear();
std::cin.ignore(1, '\n');
return "https://www.thetvdb.com" + urls[pos-1];
show = urls[pos-1].first;
return "https://www.thetvdb.com" + urls[pos-1].second;
}
void printHelp() {

View File

@ -14,7 +14,7 @@
#ifndef GUI
std::string getDefUrl( std::string show, const std::string &language, Curl &c );
std::string getDefUrl( std::string &show, const std::string &language, Curl &c );
void findSeason(std::set<std::string> &files, int season, const std::string &path);
void findSeasons(std::map<int, std::set<std::string>> &seasons, const std::string &path, const std::set<int> &season_numbers);
void printHelp();

View File

@ -49,7 +49,7 @@ void defaultSingleSeasonReturn() {
#ifdef GUI
std::vector<std::pair<std::string, std::pair<std::string, std::string>>> singleSeason( const std::string &show, int season, std::string url, const std::string &language, const std::string &pattern, const bool &linux, Curl &c, const std::set<std::string> &files) {
#else
void singleSeason( const std::string &path, const std::string &show, int season, std::string url, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c, std::set<std::string> const *files_ptr) {
void singleSeason( const std::string &path, std::string &show, int season, std::string url, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c, std::set<std::string> const *files_ptr) {
#endif
#ifndef GUI
@ -169,20 +169,20 @@ void singleSeason( const std::string &path, const std::string &show, int season,
}
#ifndef GUI
void multipleSeasons( const std::string &path, const std::string &show, const std::map<int, std::set<std::string>> &seasons, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c) {
void multipleSeasons( const std::string &path, std::string &show, const std::map<int, std::set<std::string>> &seasons, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c) {
auto url = getDefUrl(show, language, c);
for( const auto &x : seasons ) {
singleSeason( path, show, x.first, url, language, pattern, linux, trust, c, &x.second);
}
}
void multipleSeasons( const std::string &path, const std::string &show, const std::set<int> seasons, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c) {
void multipleSeasons( const std::string &path, std::string &show, const std::set<int> seasons, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c) {
std::map<int, std::set<std::string>> season_map;
findSeasons(season_map, path, seasons);
multipleSeasons(path, show, season_map, language, pattern, linux, trust, c);
}
void allSeasons( const std::string &path, const std::string &show, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c) {
void allSeasons( const std::string &path, std::string &show, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c) {
std::map<int, std::set<std::string>> seasons;
//get all season number from this directory and subdirectories
iterateFS(seasons, path);

View File

@ -12,9 +12,9 @@ std::vector<std::pair<std::string, std::pair<std::string, std::string>>> singleS
#else
void singleSeason( const std::string &path, const std::string &show, int season, std::string url, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c, std::set<std::string> const *files=nullptr);
void multipleSeasons( const std::string &path, const std::string &show, const std::set<int> seasons, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c);
void allSeasons( const std::string &path, const std::string &show, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c);
void singleSeason( const std::string &path, std::string &show, int season, std::string url, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c, std::set<std::string> const *files=nullptr);
void multipleSeasons( const std::string &path, std::string &show, const std::set<int> seasons, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c);
void allSeasons( const std::string &path, std::string &show, const std::string &language, const std::string &pattern, const bool &linux, const bool &trust, Curl &c);
#endif