From 29c9ef23c41d91603cc2860ac233c30b6ade54e3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 23 Jun 2023 22:57:40 +0200 Subject: Dramacool: fix video not working sometimes by adding support for more video backends: doodstream --- src/plugins/DramaCool.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/plugins/DramaCool.cpp') diff --git a/src/plugins/DramaCool.cpp b/src/plugins/DramaCool.cpp index df0bb43..f259f9e 100644 --- a/src/plugins/DramaCool.cpp +++ b/src/plugins/DramaCool.cpp @@ -128,6 +128,7 @@ namespace QuickMedia { std::string streamtape; std::string mixdrop; std::string mp4upload; + std::string doodstream; }; static bool dembed_extract_video_source(const std::string &website_data, const std::string &video_source_url, std::string &video_source) { @@ -149,6 +150,7 @@ namespace QuickMedia { dembed_extract_video_source(website_data, "streamtape.com", video_sources.streamtape); dembed_extract_video_source(website_data, "mixdrop.co", video_sources.mixdrop); dembed_extract_video_source(website_data, "www.mp4upload.com", video_sources.mp4upload); + dembed_extract_video_source(website_data, "dood.wf", video_sources.doodstream); } // TODO: Re-add. It's broken right now (because of the json_url has incorrect value I guess) @@ -359,6 +361,45 @@ namespace QuickMedia { return false; } + static bool generate_random_string_doodstream(char *buffer, int buffer_size) { + return generate_random_characters(buffer, buffer_size, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62); + } + + static bool doodstream_extract_video_url(const std::string &website_data, std::string &url, const std::string &referer) { + const size_t pass_start = website_data.find("/pass_md5/"); + if(pass_start == std::string::npos) + return false; + + const size_t pass_end1 = website_data.find("'", pass_start + 10); + const size_t pass_end2 = website_data.find("\"", pass_start + 10); + size_t pass_end = pass_end1; + if(pass_end2 != std::string::npos && pass_end2 < pass_end) + pass_end = pass_end2; + + if(pass_end == std::string::npos) + return false; + + const std::string pass_url = "https://dood.wf" + website_data.substr(pass_start, pass_end - pass_start); + std::string video_url; + DownloadResult result = download_to_string(pass_url, video_url, {{ "-H", "Referer: " + referer }}, true); + if(result != DownloadResult::OK) return false; + + const size_t token_start = pass_url.rfind('/'); + if(token_start == std::string::npos) + return false; + + const std::string token = pass_url.substr(token_start + 1); + + char random_str[10]; + if(!generate_random_string_doodstream(random_str, sizeof(random_str))) + return false; + + video_url.append(random_str, sizeof(random_str)); + video_url += "?token=" + token + "&expiry=" + std::to_string((int64_t)time(NULL) * 1000LL); + url = std::move(video_url); + return true; + } + PluginResult DramaCoolEpisodesPage::submit(const SubmitArgs &args, std::vector &result_tabs) { std::string website_data; DownloadResult result = download_to_string(args.url, website_data, {}, true); @@ -441,6 +482,15 @@ namespace QuickMedia { referer = "https://www.mp4upload.com"; } + if(!video_sources.doodstream.empty() && video_url.empty()) { + result = download_to_string(video_sources.doodstream, website_data, {}, true); + if(result != DownloadResult::OK) return download_result_to_plugin_result(result); + doodstream_extract_video_url(website_data, video_url, video_sources.doodstream); + + if(!video_url.empty()) + referer = "https://dood.wf"; + } + if(video_url.empty()) return PluginResult::ERR; -- cgit v1.2.3