Options: Added '--output-directory' Option
This changes where the show files are placed.
This commit is contained in:
parent
05eec0da88
commit
eb39b10284
33
src/main.cpp
33
src/main.cpp
|
@ -302,7 +302,7 @@ public:
|
||||||
bool season = false;
|
bool season = false;
|
||||||
std::string quality;
|
std::string quality;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::string series_dir;
|
std::string output_directory;
|
||||||
std::string episode;
|
std::string episode;
|
||||||
std::vector<std::string> cookies;
|
std::vector<std::string> cookies;
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ public:
|
||||||
std::cerr << "ARGUMENT PARSE ERROR: --output-directory used with too few following arguments\n";
|
std::cerr << "ARGUMENT PARSE ERROR: --output-directory used with too few following arguments\n";
|
||||||
exit(8);
|
exit(8);
|
||||||
}
|
}
|
||||||
series_dir = args[++i];
|
output_directory = args[++i];
|
||||||
}
|
}
|
||||||
else if (arg == "series") {
|
else if (arg == "series") {
|
||||||
series = true;
|
series = true;
|
||||||
|
@ -382,6 +382,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (output_directory.empty()) {
|
||||||
|
output_directory = ".";
|
||||||
|
}
|
||||||
|
|
||||||
if (season && series) {
|
if (season && series) {
|
||||||
std::cerr << "ARGUMENT PARSE ERROR: Season and Series arguments used\n";
|
std::cerr << "ARGUMENT PARSE ERROR: Season and Series arguments used\n";
|
||||||
|
@ -420,28 +423,18 @@ int main(int argc, char** argv) {
|
||||||
if (options.series) {
|
if (options.series) {
|
||||||
dropout_dl::series series(options.url, options.cookies);
|
dropout_dl::series series(options.url, options.cookies);
|
||||||
|
|
||||||
if (options.series_dir.empty()) {
|
series.download(options.quality, options.output_directory);
|
||||||
options.series_dir = series.name;
|
|
||||||
|
|
||||||
std::replace(options.series_dir.begin(), options.series_dir.end(), ' ', '_');
|
|
||||||
|
|
||||||
std::replace(options.series_dir.begin(), options.series_dir.end(), ',', '_');
|
|
||||||
}
|
|
||||||
|
|
||||||
series.download(options.quality, options.series_dir);
|
|
||||||
}
|
}
|
||||||
else if (options.season) {
|
else if (options.season) {
|
||||||
dropout_dl::season season = dropout_dl::series::get_season(options.url, options.cookies);
|
dropout_dl::season season = dropout_dl::series::get_season(options.url, options.cookies);
|
||||||
|
|
||||||
if (options.series_dir.empty()) {
|
std::string series_directory = season.series_name;
|
||||||
options.series_dir = season.series_name;
|
|
||||||
|
|
||||||
std::replace(options.series_dir.begin(), options.series_dir.end(), ' ', '_');
|
std::replace(series_directory.begin(), series_directory.end(), ' ', '_');
|
||||||
|
|
||||||
std::replace(options.series_dir.begin(), options.series_dir.end(), ',', '_');
|
std::replace(series_directory.begin(), series_directory.end(), ',', '_');
|
||||||
}
|
|
||||||
|
|
||||||
season.download(options.quality, options.series_dir);
|
season.download(options.quality, options.output_directory + "/" + series_directory);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dropout_dl::episode ep(options.url, options.cookies, options.verbose);
|
dropout_dl::episode ep(options.url, options.cookies, options.verbose);
|
||||||
|
@ -460,10 +453,6 @@ int main(int argc, char** argv) {
|
||||||
std::cout << "filename: " << options.filename << '\n';
|
std::cout << "filename: " << options.filename << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.series_dir.empty()) {
|
|
||||||
options.series_dir = ep.series;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!std::filesystem::is_directory(ep.series)) {
|
if (!std::filesystem::is_directory(ep.series)) {
|
||||||
std::filesystem::create_directories(ep.series);
|
std::filesystem::create_directories(ep.series);
|
||||||
if (options.verbose) {
|
if (options.verbose) {
|
||||||
|
@ -471,7 +460,7 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ep.download(options.quality, options.series_dir, options.filename);
|
ep.download(options.quality, options.output_directory + "/" + ep.series, options.filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,11 @@ namespace dropout_dl {
|
||||||
}
|
}
|
||||||
|
|
||||||
void season::download(const std::string &quality, const std::string &series_directory) {
|
void season::download(const std::string &quality, const std::string &series_directory) {
|
||||||
|
if (!std::filesystem::is_directory(series_directory)) {
|
||||||
|
std::filesystem::create_directories(series_directory);
|
||||||
|
std::cout << "Creating series directory" << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
std::string dir = series_directory + "/" + this->name;
|
std::string dir = series_directory + "/" + this->name;
|
||||||
|
|
||||||
std::replace(dir.begin(), dir.end(), ' ', '_');
|
std::replace(dir.begin(), dir.end(), ' ', '_');
|
||||||
|
|
|
@ -219,9 +219,14 @@ namespace dropout_dl {
|
||||||
exit(9);
|
exit(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
void series::download(const std::string &quality, const std::string &series_directory) {
|
void series::download(const std::string &quality, const std::string& base) {
|
||||||
|
if (!std::filesystem::is_directory(base + "/" + series_directory)) {
|
||||||
|
std::filesystem::create_directories(base + "/" + series_directory);
|
||||||
|
std::cout << "Creating series directory" << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
for (auto& season : seasons) {
|
for (auto& season : seasons) {
|
||||||
season.download(quality, series_directory);
|
season.download(quality, base + "/" + series_directory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace dropout_dl {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string url;
|
std::string url;
|
||||||
std::string page_data;
|
std::string page_data;
|
||||||
|
std::string series_directory;
|
||||||
std::vector<season> seasons;
|
std::vector<season> seasons;
|
||||||
|
|
||||||
static std::string get_series_name(const std::string& html_data);
|
static std::string get_series_name(const std::string& html_data);
|
||||||
|
@ -23,7 +24,7 @@ namespace dropout_dl {
|
||||||
|
|
||||||
static season get_season(const std::string& url, const std::vector<std::string>& cookies);
|
static season get_season(const std::string& url, const std::vector<std::string>& cookies);
|
||||||
|
|
||||||
void download(const std::string& quality, const std::string& series_directory);
|
void download(const std::string& quality, const std::string& base);
|
||||||
|
|
||||||
explicit series(const std::string& url, const std::vector<std::string>& cookies) {
|
explicit series(const std::string& url, const std::vector<std::string>& cookies) {
|
||||||
this->url = url;
|
this->url = url;
|
||||||
|
@ -33,6 +34,11 @@ namespace dropout_dl {
|
||||||
std::cerr << "SERIES PARSE ERROR: Could not parse series name\n";
|
std::cerr << "SERIES PARSE ERROR: Could not parse series name\n";
|
||||||
exit(10);
|
exit(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->series_directory = name;
|
||||||
|
std::replace(this->series_directory.begin(), this->series_directory.end(), ' ', '_');
|
||||||
|
std::replace(this->series_directory.begin(), this->series_directory.end(), ',', '_');
|
||||||
|
|
||||||
this->seasons = get_seasons(page_data, cookies);
|
this->seasons = get_seasons(page_data, cookies);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue