aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Manganelo.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-05 20:15:47 +0200
committerdec05eba <dec05eba@protonmail.com>2019-08-05 20:15:49 +0200
commit2b294258bbc89f1b49554468022a035782e49074 (patch)
tree33a5c0624d1bc4f9beef082988d84ab90a459f71 /src/plugins/Manganelo.cpp
parent5eb6e8a6ecd9907c422a052ed3fcd8381a375cd1 (diff)
Show current image / number of images for manga
Diffstat (limited to 'src/plugins/Manganelo.cpp')
-rw-r--r--src/plugins/Manganelo.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp
index d69aab1..6dd4ec7 100644
--- a/src/plugins/Manganelo.cpp
+++ b/src/plugins/Manganelo.cpp
@@ -95,13 +95,9 @@ namespace QuickMedia {
}
ImageResult Manganelo::get_image_by_index(const std::string &url, int index, std::string &image_data) {
- if(url != last_chapter_url) {
- last_chapter_image_urls.clear();
- ImageResult image_result = get_image_urls_for_chapter(url, last_chapter_image_urls);
- if(image_result != ImageResult::OK)
- return image_result;
- last_chapter_url = url;
- }
+ ImageResult image_result = get_image_urls_for_chapter(url);
+ if(image_result != ImageResult::OK)
+ return image_result;
int num_images = last_chapter_image_urls.size();
if(index < 0 || index >= num_images)
@@ -120,7 +116,22 @@ namespace QuickMedia {
}
}
- ImageResult Manganelo::get_image_urls_for_chapter(const std::string &url, std::vector<std::string> &urls) {
+ ImageResult Manganelo::get_number_of_images(const std::string &url, 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 = last_chapter_image_urls.size();
+ return ImageResult::OK;
+ }
+
+ ImageResult Manganelo::get_image_urls_for_chapter(const std::string &url) {
+ if(url == last_chapter_url)
+ return ImageResult::OK;
+
+ last_chapter_image_urls.clear();
+
std::string website_data;
if(download_to_string(url, website_data) != DownloadResult::OK)
return ImageResult::NET_ERR;
@@ -136,10 +147,12 @@ namespace QuickMedia {
const char *src = quickmedia_html_node_get_attribute_value(node, "src");
if(src)
urls->push_back(src);
- }, &urls);
+ }, &last_chapter_image_urls);
cleanup:
quickmedia_html_search_deinit(&html_search);
+ if(result == 0)
+ last_chapter_url = url;
return result == 0 ? ImageResult::OK : ImageResult::ERR;
}
} \ No newline at end of file