From fe52a52f12d77a55373ad0fd26df49f525a7ef35 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 7 Apr 2022 10:18:11 +0200 Subject: Fix manganelo and readm: dont use wget, and fix cloudflare bypass download to file --- src/DownloadUtils.cpp | 10 +++++++++- src/QuickMedia.cpp | 3 +-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp index a4557d2..8685662 100644 --- a/src/DownloadUtils.cpp +++ b/src/DownloadUtils.cpp @@ -199,16 +199,24 @@ namespace QuickMedia { std::vector args; if(cloudflare_bypass) { - args.insert(args.end(), { "wget", "--header", "Accept-Language: en-US,en;q=0.5", "-q", "-O", "-" }); + args.insert(args.end(), { "wget", "--header", "Accept-Language: en-US,en;q=0.5", "-q" }); // TODO: //if(fail_on_error) // args.push_back("-f"); // TODO: May not be compatible + bool additional_args_has_output_file = false; for(const CommandArg &arg : additional_args) { args.push_back(arg.option.c_str()); if(!arg.value.empty()) args.push_back(arg.value.c_str()); + + if(arg.option == "-o") + additional_args_has_output_file = true; } + + if(!additional_args_has_output_file) + args.insert(args.end(), { "-O", "-" }); + if(use_browser_useragent) { args.push_back("--header"); args.push_back(useragent_str); diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 101fa59..45c0bd1 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3846,7 +3846,6 @@ namespace QuickMedia { std::vector extra_args; const bool is_manganelo = (strcmp(images_page->get_service_name(), "manganelo") == 0); const char *website_url = images_page->get_website_url(); - const bool cloudflare_bypass = (strcmp(images_page->get_service_name(), "manganelo") == 0 || strcmp(images_page->get_service_name(), "readm") == 0); if(is_manganelo) { extra_args = { CommandArg { "-H", "accept: image/jpeg,image/png,image/*,*/*;q=0.8" }, @@ -3876,7 +3875,7 @@ namespace QuickMedia { } } else { int64_t file_size = 0; - if(download_to_file(url, image_filepath_tmp.data, extra_args, true, cloudflare_bypass) != DownloadResult::OK || (is_manganelo && file_get_size(image_filepath_tmp, &file_size) == 0 && file_size < 255)) { + if(download_to_file(url, image_filepath_tmp.data, extra_args, true) != DownloadResult::OK || (is_manganelo && file_get_size(image_filepath_tmp, &file_size) == 0 && file_size < 255)) { if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL); return true; } -- cgit v1.2.3