aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp50
1 files changed, 13 insertions, 37 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index a5318be..c478876 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1520,7 +1520,7 @@ namespace QuickMedia {
if(associated_data.fetching_next_page_running && associated_data.next_page_future.ready()) {
BodyItems new_body_items = associated_data.next_page_future.get();
- fprintf(stderr, "Finished fetching page %d, num new messages: %zu\n", associated_data.fetched_page + 1, new_body_items.size());
+ fprintf(stderr, "Finished fetching page %d, num new items: %zu\n", associated_data.fetched_page + 1, new_body_items.size());
size_t num_new_messages = new_body_items.size();
if(num_new_messages > 0) {
tabs[i].body->append_items(std::move(new_body_items));
@@ -2130,7 +2130,7 @@ namespace QuickMedia {
return true;
});
- fprintf(stderr, "Finished fetching page %d, num new messages: %zu\n", fetch_page, new_body_items.size());
+ fprintf(stderr, "Finished fetching page %d, num new items: %zu\n", fetch_page, new_body_items.size());
size_t num_new_messages = new_body_items.size();
if(num_new_messages > 0) {
next_play_items.insert(next_play_items.end(), new_body_items.begin(), new_body_items.end());
@@ -2315,48 +2315,24 @@ namespace QuickMedia {
return true;
std::vector<CommandArg> extra_args;
- if(strcmp(images_page->get_service_name(), "manganelo") == 0) {
+ const bool is_manganelo = (strcmp(images_page->get_service_name(), "manganelo") == 0);
+ if(is_manganelo) {
extra_args = {
- CommandArg { "-H", "accept: image/png,image/*,*/*;q=0.8" },
+ CommandArg { "-H", "accept: image/jpeg,image/png,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/" }
+ CommandArg { "-H", "referer: https://manganelo.com/" },
+ CommandArg { "-m", "30" },
+ CommandArg { "--connect-timeout", "30" }
};
}
- // TODO: Download directly to file instead. TODO: Move to page
- std::string image_content;
- if(download_to_string(url, image_content, extra_args, true) != DownloadResult::OK || image_content.size() <= 255) {
- if(strcmp(images_page->get_service_name(), "manganelo") == 0) {
- bool try_backup_url = false;
- std::string new_url = url;
- if(string_replace_all(new_url, "s3.mkklcdnv3.com", "bu.mkklcdnbuv1.com") > 0) {
- try_backup_url = true;
- } else {
- try_backup_url = (string_replace_all(new_url, "s41.mkklcdnv41.com", "bu.mkklcdnbuv1.com") > 0);
- }
-
- if(try_backup_url) {
- image_content.clear();
- if(download_to_string(new_url, image_content, extra_args, true) != DownloadResult::OK || image_content.size() <= 255) {
- if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + new_url, Urgency::CRITICAL);
- return true;
- }
- } else {
- if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
- return true;
- }
- } else {
- if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
- return true;
- }
- }
-
- Path image_filepath_tmp(image_filepath.data + ".tmp");
-
- if(file_overwrite(image_filepath_tmp, image_content) != 0) {
- show_notification("QuickMedia", "Failed to save image to file: " + image_filepath_tmp.data, Urgency::CRITICAL);
+ Path image_filepath_tmp(image_filepath.data + ".tmpz");
+ // TODO: Move to page
+ size_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)) {
+ if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
return true;
}