Fewer filesystem operations when using multipleSeasons
This commit is contained in:
parent
46abfe3dd9
commit
769f8508a4
@ -104,6 +104,22 @@ void findSeason(std::set<std::string> &files, int season, const std::string &pat
|
||||
}
|
||||
}
|
||||
|
||||
void findSeasons(std::map<int, std::set<std::string>> &seasons, const std::string &path, const std::set<int> &season_numbers) {
|
||||
size_t season_pos{std::string::npos}; // season_pos - position of first digit of the season
|
||||
for( const auto p: FSLib::Directory(path) ) {
|
||||
if(FSLib::isDirectory(path + "/" + p)) {
|
||||
iterateFS(seasons, path + "/" + p);
|
||||
continue;
|
||||
}
|
||||
|
||||
if( searchSeason(p, season_pos) ) {
|
||||
auto num = atoi(p+season_pos);
|
||||
if( season_numbers.find(num) != season_numbers.end() )
|
||||
seasons[num].insert(path + "/" + p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void iterateFS(std::map<int, std::set<std::string>> &seasons, const std::string &path) {
|
||||
size_t season_pos{std::string::npos}; // season_pos - position of first digit of the season
|
||||
for( const auto p: FSLib::Directory(path) ) {
|
||||
|
@ -17,6 +17,7 @@ private:
|
||||
|
||||
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 iterateFS(std::map<int, std::set<std::string>> &seasons, const std::string &path);
|
||||
void iterateFS(std::set<int> &seasons, const std::string &path);
|
||||
void printHelp();
|
||||
|
@ -303,13 +303,6 @@ void singleSeason( const std::string &path, const std::string &show, int season,
|
||||
}
|
||||
}
|
||||
|
||||
void multipleSeasons( const std::string &path, const std::string &show, const std::set<int> seasons, const std::string &language, const bool &linux, const bool &trust, Curl &c) {
|
||||
auto url = getDefUrl(show, language, c);
|
||||
for( const auto &x : seasons ) {
|
||||
singleSeason( path, show, x, url, language, linux, trust, c);
|
||||
}
|
||||
}
|
||||
|
||||
void multipleSeasons( const std::string &path, const std::string &show, const std::map<int, std::set<std::string>> &seasons, const std::string &language, const bool &linux, const bool &trust, Curl &c) {
|
||||
auto url = getDefUrl(show, language, c);
|
||||
for( const auto &x : seasons ) {
|
||||
@ -317,6 +310,12 @@ void multipleSeasons( const std::string &path, const std::string &show, const st
|
||||
}
|
||||
}
|
||||
|
||||
void multipleSeasons( const std::string &path, const std::string &show, const std::set<int> seasons, const std::string &language, 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, linux, trust, c);
|
||||
}
|
||||
|
||||
void allSeasons( const std::string &path, const std::string &show, const std::string &language, 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
|
||||
|
Loading…
Reference in New Issue
Block a user