From b5c3e1e3bc608bd5071972fa68a122f7ae5521d8 Mon Sep 17 00:00:00 2001 From: Moss Date: Wed, 28 Sep 2022 22:22:20 -0400 Subject: [PATCH] Quality: Added 'all' Quality Option This allows for the user to download all qualities at once and have them be automatically placed into quality folders. --- src/episode.h | 2 +- src/main.cpp | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/episode.h b/src/episode.h index 4b49451..1fe4453 100644 --- a/src/episode.h +++ b/src/episode.h @@ -113,7 +113,7 @@ namespace dropout_dl { std::replace(this->series.begin(), this->series.end(), ',', '_'); - this->filename = this->series + "/S" + (this->season_number.size() < 2 ? "0" + this->season_number : this->season_number) + "E" + (this->episode_number.size() < 2 ? "0" + this->episode_number : this->episode_number) + this->name + ".mp4"; + this->filename = "S" + (this->season_number.size() < 2 ? "0" + this->season_number : this->season_number) + "E" + (this->episode_number.size() < 2 ? "0" + this->episode_number : this->episode_number) + this->name + ".mp4"; std::replace(filename.begin(), filename.end(), ' ', '_'); diff --git a/src/main.cpp b/src/main.cpp index 76c4806..59dbd2e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,7 +11,6 @@ #endif #endif - static int sqlite_write_callback(void* data, int argc, char** argv, char** azColName) { if (argc < 1) { @@ -298,8 +297,8 @@ std::vector get_cookies(bool verbose = false) { int main(int argc, char** argv) { - bool verbose = true; - std::string quality = "1080p"; + bool verbose = false; + std::string quality = "all"; std::string firefox_profile; std::string chrome_profile; @@ -325,12 +324,6 @@ int main(int argc, char** argv) { dropout_dl::episode ep(episode_url, cookies, verbose); - std::string video_url = ep.get_video_url(quality); - if (verbose) { - std::cout << "Got video url: " << video_url << '\n'; - } - - if (!std::filesystem::is_directory(ep.series)) { std::filesystem::create_directories(ep.series); if (verbose) { @@ -338,9 +331,25 @@ int main(int argc, char** argv) { } } - std::fstream out(ep.filename, std::ios_base::in|std::ios_base::out|std::ios_base::trunc); + if (quality == "all") { + for (const auto& possible_quality : ep.qualities) { + if (!std::filesystem::is_directory(ep.series + "/" + possible_quality)) { + std::filesystem::create_directories(ep.series + "/" + possible_quality); + if (verbose) { + std::cout << "Creating series directory" << '\n'; + } + } + std::fstream out(ep.series + "/" + possible_quality + "/" + ep.filename, + std::ios_base::in | std::ios_base::out | std::ios_base::trunc); - out << ep.get_video_data(quality) << std::endl; + out << ep.get_video_data(possible_quality) << std::endl; + } + } + else { + std::fstream out(ep.series + "/" + ep.filename, std::ios_base::in | std::ios_base::out | std::ios_base::trunc); + + out << ep.get_video_data(quality) << std::endl; + } return 0; }