aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Manganelo.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-04-14 19:52:21 +0200
committerdec05eba <dec05eba@protonmail.com>2021-04-14 23:45:11 +0200
commitab36fbffef977b99cc03d0b77ac37bdc1b5705dc (patch)
tree17207a364eecee330a26ac117a1384ad0b4a1e97 /src/plugins/Manganelo.cpp
parent4db0876f45533d3b55ee79df2d2bc78b789b5a28 (diff)
Rework manga plugins downloading.. preparing for parallel downloads
Diffstat (limited to 'src/plugins/Manganelo.cpp')
-rw-r--r--src/plugins/Manganelo.cpp41
1 files changed, 6 insertions, 35 deletions
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<std::string> 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<std::string> &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