From ab36fbffef977b99cc03d0b77ac37bdc1b5705dc Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 14 Apr 2021 19:52:21 +0200 Subject: Rework manga plugins downloading.. preparing for parallel downloads --- src/plugins/Manganelo.cpp | 41 ++++++----------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) (limited to 'src/plugins/Manganelo.cpp') diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp index 8ce9e01..b67acb2 100644 --- a/src/plugins/Manganelo.cpp +++ b/src/plugins/Manganelo.cpp @@ -226,36 +226,7 @@ namespace QuickMedia { return PluginResult::OK; } - ImageResult ManganeloImagesPage::get_number_of_images(int &num_images) { - num_images = 0; - ImageResult image_result = get_image_urls_for_chapter(url); - if(image_result != ImageResult::OK) - return image_result; - - num_images = chapter_image_urls.size(); - return ImageResult::OK; - } - - ImageResult ManganeloImagesPage::for_each_page_in_chapter(PageCallback callback) { - std::vector image_urls; - ImageResult image_result = get_image_urls_for_chapter(url); - if(image_result != ImageResult::OK) - return image_result; - - image_urls = chapter_image_urls; - - for(const std::string &url : image_urls) { - if(!callback(url)) - break; - } - - return ImageResult::OK; - } - - ImageResult ManganeloImagesPage::get_image_urls_for_chapter(const std::string &url) { - if(!chapter_image_urls.empty()) - return ImageResult::OK; - + ImageResult ManganeloImagesPage::get_page_image_urls(std::vector &urls) { std::string website_data; if(download_to_string(url, website_data, {}, true) != DownloadResult::OK) return ImageResult::NET_ERR; @@ -273,16 +244,16 @@ namespace QuickMedia { std::string image_url = strip(src); urls->push_back(std::move(image_url)); } - }, &chapter_image_urls); + }, &urls); cleanup: quickmedia_html_search_deinit(&html_search); - if(result != 0) { - chapter_image_urls.clear(); + if(result != 0) return ImageResult::ERR; - } - if(chapter_image_urls.empty()) + + if(urls.empty()) return ImageResult::ERR; + return ImageResult::OK; } } \ No newline at end of file -- cgit v1.2.3