From 19a379bd0485e6c3b85391a1017f6efa80d43ab6 Mon Sep 17 00:00:00 2001 From: Moss Date: Sun, 25 Dec 2022 00:43:45 -0500 Subject: [PATCH] Season: Manually Give Episodes In The Season The Series and Season --- src/episode.h | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/season.cpp | 9 +++--- src/season.h | 2 ++ 3 files changed, 87 insertions(+), 5 deletions(-) diff --git a/src/episode.h b/src/episode.h index 9cccf56..57f1789 100644 --- a/src/episode.h +++ b/src/episode.h @@ -406,6 +406,87 @@ namespace dropout_dl { */ void download(const std::string& quality, const std::string& series_directory, std::string filename = ""); + + + /** + * + * @param episode_url - Link to the episode + * @param cookies - The current cookies from the browser + * @param series - The series the episode is in + * @param season - The season the episode is in + * @param episode_number - The number of the episode + * @param season_number - The number of the season the episode is in + * @param verbose - Whether or not be verbose + * + * Create an episode object from the link using to cookies to get all the necessary information. + * This constructor initializes all the object data. + */ + episode(const std::string& episode_url, std::vector cookies, const std::string& series, const std::string& season, int episode_number, int season_number, bool verbose = false) { + this->episode_url = episode_url; + this->verbose = verbose; + + episode_data = get_episode_page(episode_url, cookies[0].value, cookies[1].value); + + if (verbose) { + std::cout << "Got page data\n"; + } + + metadata = get_meta_data_json(episode_data); + + if (verbose) { + std::cout << "Got episode metadata: " << metadata << '\n'; + } + + name = get_episode_name(metadata); + + if (verbose) { + std::cout << "Got name: " << name << '\n'; + } + + if (name == "ERROR") { + std::cerr << "EPISODE ERROR: Invalid Episode URL\n"; + exit(6); + } + + this->series = series; + + this->series_directory = format_filename(this->series); + + this->season = season; + + this->episode_number = episode_number; + + this->season_number = season_number; + + + this->embedded_url = get_embed_url(episode_data); + + replace_all(this->embedded_url, "&", "&"); + + if (verbose) { + std::cout << "Got embedded url: " << this->embedded_url << '\n'; + } + + this->embedded_page_data = get_generic_page(this->embedded_url); + + if (this->embedded_page_data.find("you are not authorized") != std::string::npos) { + std::cerr << "ERROR: Could not access video. Try refreshing cookies.\n"; + exit(6); + } + + this->config_url = get_config_url(this->embedded_page_data); + + replace_all(this->config_url, "\\u0026", "&"); + + if (verbose) { + std::cout << "Got config url: " << this->config_url << '\n'; + } + + this->config_data = get_generic_page(this->config_url); + + this->get_qualities(); + } + /** * * @param episode_url - Link to the episode diff --git a/src/season.cpp b/src/season.cpp index 4bb2c0e..eadd461 100644 --- a/src/season.cpp +++ b/src/season.cpp @@ -5,7 +5,7 @@ #include "season.h" namespace dropout_dl { - episode get_episode(const std::string& html_data, int& start_point, const std::vector& cookies) { + episode season::get_episode(const std::string& html_data, int& start_point, const std::vector& cookies, int episode_number) { int link_start = 0; for (int i = start_point; i > 0; i--) { if (substr_is(html_data, i, "series_name, this->name, episode_number, this->season_number}; } } } @@ -41,12 +41,11 @@ namespace dropout_dl { int number_of_episodes = 0; for (int i = 0; i < this->page_data.size(); i++) { if (substr_is(this->page_data, i, site_video)) { - episode e = get_episode(this->page_data, i, cookies); + episode e = get_episode(this->page_data, i, cookies, number_of_episodes + 1); if (e.episode_url.empty()) { continue; } - e.episode_number = ++number_of_episodes; - e.season_number = this->season_number; + number_of_episodes++; std::cout << '\t' << e.name << '\n'; out.push_back(e); } diff --git a/src/season.h b/src/season.h index 4d0b3a0..d4298ce 100644 --- a/src/season.h +++ b/src/season.h @@ -25,6 +25,8 @@ namespace dropout_dl { /// The list of all the episodes in the season std::vector episodes; + episode get_episode(const std::string& html_data, int& start_point, const std::vector& cookies, int episode_number = 0); + /** * * @param html_data - The season page data