Use thetvdb name of show in '%show'
This commit is contained in:
parent
4c8922b619
commit
3d4c355342
@ -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(), ' ', '+');
|
std::replace(show.begin(), show.end(), ' ', '+');
|
||||||
auto source_code = c.execute("https://www.thetvdb.com/search?q=" + encodeUrl(show) + "&l=" + language);
|
auto source_code = c.execute("https://www.thetvdb.com/search?q=" + encodeUrl(show) + "&l=" + language);
|
||||||
size_t order{}, pos{};
|
size_t order{}, pos{};
|
||||||
std::vector<std::string> urls;
|
std::vector<std::pair<std::string, std::string>> urls;
|
||||||
while( true ) {
|
while( true ) {
|
||||||
pos = source_code.find("/ser", pos);
|
pos = source_code.find("/ser", pos);
|
||||||
if( pos != std::string::npos ) {
|
if( pos != std::string::npos ) {
|
||||||
auto end = source_code.find(">", pos);
|
auto end = source_code.find(">", pos);
|
||||||
end--;
|
end--;
|
||||||
urls.push_back(source_code.substr(pos, end - pos));
|
auto end2 = source_code.find("<", end + 2);
|
||||||
pos = end + 2;
|
urls.emplace_back(source_code.substr(end + 2, end2 - end - 2), source_code.substr(pos, end - pos));
|
||||||
end = source_code.find("<", pos);
|
std::cout << ++order << ". " << urls.back().first << std::endl;
|
||||||
std::cout << ++order << ". " << source_code.substr(pos, end - pos) << std::endl;
|
pos = end2;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -170,7 +170,8 @@ std::string getDefUrl( std::string show, const std::string &language, Curl &c )
|
|||||||
std::cin >> pos;
|
std::cin >> pos;
|
||||||
std::cin.clear();
|
std::cin.clear();
|
||||||
std::cin.ignore(1, '\n');
|
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() {
|
void printHelp() {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#ifndef GUI
|
#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 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 findSeasons(std::map<int, std::set<std::string>> &seasons, const std::string &path, const std::set<int> &season_numbers);
|
||||||
void printHelp();
|
void printHelp();
|
||||||
|
@ -49,7 +49,7 @@ void defaultSingleSeasonReturn() {
|
|||||||
#ifdef GUI
|
#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) {
|
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
|
#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
|
#endif
|
||||||
|
|
||||||
#ifndef GUI
|
#ifndef GUI
|
||||||
@ -169,20 +169,20 @@ void singleSeason( const std::string &path, const std::string &show, int season,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef GUI
|
#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);
|
auto url = getDefUrl(show, language, c);
|
||||||
for( const auto &x : seasons ) {
|
for( const auto &x : seasons ) {
|
||||||
singleSeason( path, show, x.first, url, language, pattern, linux, trust, c, &x.second);
|
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;
|
std::map<int, std::set<std::string>> season_map;
|
||||||
findSeasons(season_map, path, seasons);
|
findSeasons(season_map, path, seasons);
|
||||||
multipleSeasons(path, show, season_map, language, pattern, linux, trust, c);
|
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;
|
std::map<int, std::set<std::string>> seasons;
|
||||||
//get all season number from this directory and subdirectories
|
//get all season number from this directory and subdirectories
|
||||||
iterateFS(seasons, path);
|
iterateFS(seasons, path);
|
||||||
|
@ -12,9 +12,9 @@ std::vector<std::pair<std::string, std::pair<std::string, std::string>>> singleS
|
|||||||
|
|
||||||
#else
|
#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 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, 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);
|
||||||
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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user