From 2ba21aa9aa91b975fe0c8be630dde05d0d9b5366 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 13 Oct 2019 03:32:07 +0200 Subject: Manganelo: Download all images at once, and show page after it has downloaded --- plugins/Fourchan.hpp | 1 + plugins/Manganelo.hpp | 9 +++++++++ plugins/Plugin.hpp | 3 +++ plugins/Pornhub.hpp | 1 + plugins/Youtube.hpp | 1 + 5 files changed, 15 insertions(+) (limited to 'plugins') diff --git a/plugins/Fourchan.hpp b/plugins/Fourchan.hpp index d6b482b..7f9ad13 100644 --- a/plugins/Fourchan.hpp +++ b/plugins/Fourchan.hpp @@ -5,6 +5,7 @@ namespace QuickMedia { class Fourchan : public Plugin { public: + Fourchan() : Plugin("4chan") {} PluginResult get_front_page(BodyItems &result_items) override; SearchResult search(const std::string &url, BodyItems &result_items) override; SuggestionResult update_search_suggestions(const std::string &text, BodyItems &result_items) override; diff --git a/plugins/Manganelo.hpp b/plugins/Manganelo.hpp index ab3bb3f..3405de2 100644 --- a/plugins/Manganelo.hpp +++ b/plugins/Manganelo.hpp @@ -1,10 +1,16 @@ #pragma once #include "Plugin.hpp" +#include +#include namespace QuickMedia { + // Return false to stop iteration + using PageCallback = std::function; + class Manganelo : public Plugin { public: + Manganelo() : Plugin("manganelo") {} SearchResult search(const std::string &url, BodyItems &result_items) override; SuggestionResult update_search_suggestions(const std::string &text, BodyItems &result_items) override; ImageResult get_image_by_index(const std::string &url, int index, std::string &image_data); @@ -13,11 +19,14 @@ namespace QuickMedia { bool search_results_has_thumbnails() const override { return false; } int get_search_delay() const override { return 150; } Page get_page_after_search() const override { return Page::EPISODE_LIST; } + + ImageResult for_each_page_in_chapter(const std::string &chapter_url, PageCallback callback); private: // Caches url. If the same url is requested multiple times then the cache is used ImageResult get_image_urls_for_chapter(const std::string &url); private: std::string last_chapter_url; std::vector last_chapter_image_urls; + std::mutex image_urls_mutex; }; } \ No newline at end of file diff --git a/plugins/Plugin.hpp b/plugins/Plugin.hpp index d5802af..dffe898 100644 --- a/plugins/Plugin.hpp +++ b/plugins/Plugin.hpp @@ -50,6 +50,7 @@ namespace QuickMedia { class Plugin { public: + Plugin(const std::string &name) : name(name) {} virtual ~Plugin() = default; virtual PluginResult get_front_page(BodyItems &result_items) { @@ -74,6 +75,8 @@ namespace QuickMedia { virtual int get_search_delay() const = 0; virtual bool search_suggestion_is_search() const { return false; } virtual Page get_page_after_search() const = 0; + + const std::string name; protected: std::string url_param_encode(const std::string ¶m) const; }; diff --git a/plugins/Pornhub.hpp b/plugins/Pornhub.hpp index edbfdab..188a68e 100644 --- a/plugins/Pornhub.hpp +++ b/plugins/Pornhub.hpp @@ -5,6 +5,7 @@ namespace QuickMedia { class Pornhub : public Plugin { public: + Pornhub() : Plugin("pornhub") {} SuggestionResult update_search_suggestions(const std::string &text, BodyItems &result_items) override; BodyItems get_related_media(const std::string &url) override; bool search_suggestions_has_thumbnails() const override { return true; } diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index 4ca7955..a676cd0 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -5,6 +5,7 @@ namespace QuickMedia { class Youtube : public Plugin { public: + Youtube() : Plugin("youtube") {} SuggestionResult update_search_suggestions(const std::string &text, BodyItems &result_items) override; BodyItems get_related_media(const std::string &url) override; bool search_suggestions_has_thumbnails() const override { return true; } -- cgit v1.2.3