aboutsummaryrefslogtreecommitdiff
path: root/plugins/Mangatown.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-11 21:35:37 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-13 13:13:01 +0200
commit77ed51898157d99112be7550471ec06e32344c9e (patch)
tree0645274d0f13b4fa6940d4054f74a070611a8ef0 /plugins/Mangatown.hpp
parentda89ec98fb34757f0c46dc8cb2dd87ae78d317ce (diff)
Refactor plugin into seperate pages
TODO: Readd 4chan login page, manganelo creators page, autocomplete
Diffstat (limited to 'plugins/Mangatown.hpp')
-rw-r--r--plugins/Mangatown.hpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/plugins/Mangatown.hpp b/plugins/Mangatown.hpp
index 2a22ccd..c85b5b7 100644
--- a/plugins/Mangatown.hpp
+++ b/plugins/Mangatown.hpp
@@ -2,26 +2,34 @@
#include "Manga.hpp"
#include <functional>
-#include <mutex>
namespace QuickMedia {
- class Mangatown : public Manga {
+ class MangatownSearchPage : public Page {
public:
- Mangatown() : Manga("mangatown") {}
- SearchResult search(const std::string &url, BodyItems &result_items) override;
- SuggestionResult update_search_suggestions(const std::string &text, BodyItems &result_items) override;
- ImageResult get_number_of_images(const std::string &url, int &num_images) override;
- bool search_suggestions_has_thumbnails() const override { return true; }
- bool search_results_has_thumbnails() const override { return false; }
- int get_search_delay() const override { return 200; }
- Page get_page_after_search() const override { return Page::EPISODE_LIST; }
+ MangatownSearchPage(Program *program) : Page(program) {}
+ const char* get_title() const override { return "All"; }
+ bool search_is_filter() override { return false; }
+ SearchResult search(const std::string &str, BodyItems &result_items) override;
+ PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ private:
+ bool extract_id_from_url(const std::string &url, std::string &manga_id) const;
+ };
+
+ class MangatownChaptersPage : public MangaChaptersPage {
+ public:
+ MangatownChaptersPage(Program *program, std::string manga_name, std::string manga_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)) {}
+ PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ };
+
+ class MangatownImagesPage : public MangaImagesPage {
+ public:
+ MangatownImagesPage(Program *program, std::string manga_name, std::string chapter_name, std::string url) : MangaImagesPage(program, std::move(manga_name), std::move(chapter_name), std::move(url)) {}
- ImageResult for_each_page_in_chapter(const std::string &chapter_url, PageCallback callback) override;
+ ImageResult get_number_of_images(int &num_images) override;
+ ImageResult for_each_page_in_chapter(PageCallback callback) override;
- bool extract_id_from_url(const std::string &url, std::string &manga_id) override;
+ const char* get_service_name() const override { return "mangatown"; }
private:
- std::string last_chapter_url_num_images;
- int last_num_pages = 0;
- std::mutex image_urls_mutex;
+ ImageResult get_image_urls_for_chapter(const std::string &url);
};
} \ No newline at end of file