Season: Manually Give Episodes In The Season The Series and Season

This commit is contained in:
Moss 2022-12-25 00:43:45 -05:00
parent 24adf6446b
commit 19a379bd04
No known key found for this signature in database
GPG Key ID: F539D4A506C954F9
3 changed files with 87 additions and 5 deletions

View File

@ -406,6 +406,87 @@ namespace dropout_dl {
*/ */
void download(const std::string& quality, const std::string& series_directory, std::string filename = ""); 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<cookie> 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, "&amp;", "&");
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 * @param episode_url - Link to the episode

View File

@ -5,7 +5,7 @@
#include "season.h" #include "season.h"
namespace dropout_dl { namespace dropout_dl {
episode get_episode(const std::string& html_data, int& start_point, const std::vector<cookie>& cookies) { episode season::get_episode(const std::string& html_data, int& start_point, const std::vector<cookie>& cookies, int episode_number) {
int link_start = 0; int link_start = 0;
for (int i = start_point; i > 0; i--) { for (int i = start_point; i > 0; i--) {
if (substr_is(html_data, i, "<a")) { if (substr_is(html_data, i, "<a")) {
@ -24,7 +24,7 @@ namespace dropout_dl {
for (int j = 0; j + i < html_data.size(); j++) { for (int j = 0; j + i < html_data.size(); j++) {
if (html_data[i + j] == '"') { if (html_data[i + j] == '"') {
start_point += 15; start_point += 15;
return {html_data.substr(i, j), cookies}; return {html_data.substr(i, j), cookies, this->series_name, this->name, episode_number, this->season_number};
} }
} }
} }
@ -41,12 +41,11 @@ namespace dropout_dl {
int number_of_episodes = 0; int number_of_episodes = 0;
for (int i = 0; i < this->page_data.size(); i++) { for (int i = 0; i < this->page_data.size(); i++) {
if (substr_is(this->page_data, i, site_video)) { 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()) { if (e.episode_url.empty()) {
continue; continue;
} }
e.episode_number = ++number_of_episodes; number_of_episodes++;
e.season_number = this->season_number;
std::cout << '\t' << e.name << '\n'; std::cout << '\t' << e.name << '\n';
out.push_back(e); out.push_back(e);
} }

View File

@ -25,6 +25,8 @@ namespace dropout_dl {
/// The list of all the episodes in the season /// The list of all the episodes in the season
std::vector<episode> episodes; std::vector<episode> episodes;
episode get_episode(const std::string& html_data, int& start_point, const std::vector<cookie>& cookies, int episode_number = 0);
/** /**
* *
* @param html_data - The season page data * @param html_data - The season page data