aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-08-17 18:35:42 +0200
committerdec05eba <dec05eba@protonmail.com>2022-08-17 18:35:42 +0200
commit47a057cc5a7b26d150bfa9b081bf081542280344 (patch)
treefa29f16a30670dbda058500fd08774de02a93243 /src
parenta068d8ec52f238e271fb8ba396f6024fd817eb4a (diff)
Mangakatana: try different image mirror if download fails
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index ebd6ac4..7770f1e 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3862,6 +3862,7 @@ namespace QuickMedia {
std::vector<CommandArg> extra_args;
const bool is_manganelo = (strcmp(images_page->get_service_name(), "manganelo") == 0);
+ const bool is_mangakatana = (strcmp(images_page->get_service_name(), "mangakatana") == 0);
const char *website_url = images_page->get_website_url();
if(is_manganelo) {
extra_args = {
@@ -3892,9 +3893,25 @@ namespace QuickMedia {
}
} else {
int64_t file_size = 0;
- 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)) {
+ bool download_success = download_to_file(url, image_filepath_tmp.data, extra_args, true) == DownloadResult::OK;
+ if(!download_success) {
+ remove(image_filepath_tmp.data.c_str());
if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
return true;
+ } else if(is_manganelo && file_get_size(image_filepath_tmp, &file_size) == 0 && file_size < 255) {
+ remove(image_filepath_tmp.data.c_str());
+ if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
+ return true;
+ } else if(is_mangakatana && file_get_size(image_filepath_tmp, &file_size) == 0 && file_size < 255) {
+ remove(image_filepath_tmp.data.c_str());
+ std::string new_url = url;
+ string_replace_all(new_url, "://i3", "://i2");
+
+ download_success = download_to_file(new_url, image_filepath_tmp.data, extra_args, true) == DownloadResult::OK;
+ if(!download_success) {
+ if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
+ return true;
+ }
}
}