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 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/QuickMedia.cpp') 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; } -- cgit v1.2.3