From 169057193c664f52267b818b2ff8bdcf73f21747 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 12 Aug 2020 17:24:06 +0200 Subject: Fix manganelo images not loading (cloudflare ddos protection) --- src/QuickMedia.cpp | 15 +++++++++++++-- src/plugins/Manganelo.cpp | 2 -- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index a7fca2d..d3627e1 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1246,8 +1246,19 @@ namespace QuickMedia { if(get_file_type(image_filepath) != FileType::FILE_NOT_FOUND) return true; + std::vector extra_args; + if(current_plugin->name == "manganelo") { + extra_args = { + CommandArg { "-H", "accept: image/webp,image/apng,image/*,*/*;q=0.8" }, + CommandArg { "-H", "sec-fetch-site: cross-site" }, + CommandArg { "-H", "sec-fetch-mode: no-cors" }, + CommandArg { "-H", "sec-fetch-dest: image" }, + CommandArg { "-H", "referer: https://manganelo.com/" } + }; + } + std::string image_content; - if(download_to_string(url, image_content, {}, current_plugin->use_tor) != DownloadResult::OK || image_content.size() <= 255) { + if(download_to_string(url, image_content, extra_args, current_plugin->use_tor, true) != DownloadResult::OK || image_content.size() <= 255) { if(current_plugin->name == "manganelo") { bool try_backup_url = false; std::string new_url = url; @@ -1259,7 +1270,7 @@ namespace QuickMedia { if(try_backup_url) { image_content.clear(); - if(download_to_string(new_url, image_content, {}, current_plugin->use_tor) != DownloadResult::OK || image_content.size() <= 255) { + if(download_to_string(new_url, image_content, extra_args, current_plugin->use_tor, true) != DownloadResult::OK || image_content.size() <= 255) { show_notification("Manganelo", "Failed to download image: " + new_url, Urgency::CRITICAL); return false; } diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp index 89f882c..a4c8809 100644 --- a/src/plugins/Manganelo.cpp +++ b/src/plugins/Manganelo.cpp @@ -125,9 +125,7 @@ namespace QuickMedia { auto *urls = (std::vector*)userdata; const char *src = quickmedia_html_node_get_attribute_value(node, "src"); if(src) { - // TODO: If image loads too slow, try switching mirror std::string image_url = src; - //string_replace_all(image_url, "s3.mkklcdnv3.com", "bu.mkklcdnbuv1.com"); urls->emplace_back(std::move(image_url)); } }, &last_chapter_image_urls); -- cgit v1.2.3