diff options
Diffstat (limited to 'src/plugins/Manganelo.cpp')
-rw-r--r-- | src/plugins/Manganelo.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp index b67acb2..e63ff6c 100644 --- a/src/plugins/Manganelo.cpp +++ b/src/plugins/Manganelo.cpp @@ -226,7 +226,28 @@ namespace QuickMedia { return PluginResult::OK; } - ImageResult ManganeloImagesPage::get_page_image_urls(std::vector<std::string> &urls) { + 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) { + ImageResult image_result = get_image_urls_for_chapter(url); + if(image_result != ImageResult::OK) return image_result; + for(const std::string &url : chapter_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; + std::string website_data; if(download_to_string(url, website_data, {}, true) != DownloadResult::OK) return ImageResult::NET_ERR; @@ -244,16 +265,14 @@ namespace QuickMedia { std::string image_url = strip(src); urls->push_back(std::move(image_url)); } - }, &urls); + }, &chapter_image_urls); cleanup: quickmedia_html_search_deinit(&html_search); - if(result != 0) - return ImageResult::ERR; - - if(urls.empty()) + if(result != 0 || chapter_image_urls.empty()) { + chapter_image_urls.clear(); return ImageResult::ERR; - + } return ImageResult::OK; } }
\ No newline at end of file |