From 5cc735b22570f1667d62958e59ce4910b529f5af Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 16 Aug 2021 21:13:24 +0200 Subject: Add MyAnimeList (wip) --- plugins/HotExamples.hpp | 4 ++-- plugins/Info.hpp | 2 +- plugins/MangaCombined.hpp | 1 - plugins/MangaGeneric.hpp | 2 -- plugins/Mangadex.hpp | 1 - plugins/Manganelo.hpp | 2 -- plugins/Matrix.hpp | 8 ++++---- plugins/MediaGeneric.hpp | 1 - plugins/MyAnimeList.hpp | 36 ++++++++++++++++++++++++++++++++++++ plugins/NyaaSi.hpp | 4 ++-- plugins/Page.hpp | 4 +--- 11 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 plugins/MyAnimeList.hpp (limited to 'plugins') diff --git a/plugins/HotExamples.hpp b/plugins/HotExamples.hpp index 154f1ab..73bc150 100644 --- a/plugins/HotExamples.hpp +++ b/plugins/HotExamples.hpp @@ -10,7 +10,7 @@ namespace QuickMedia { HotExamplesLanguageSelectPage(Program *program) : Page(program) {} const char* get_title() const override { return "Select language"; } PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - bool submit_is_async() override { return false; } + bool submit_is_async() const override { return false; } }; class HotExamplesSearchPage : public Page { @@ -29,7 +29,7 @@ namespace QuickMedia { HotExamplesCodeExamplesPage(Program *program, std::string title) : Page(program), title(std::move(title)) {} const char* get_title() const override { return title.c_str(); } PluginResult submit(const std::string&, const std::string&, std::vector&) override { return PluginResult::OK; } - bool submit_is_async() override { return false; } + bool submit_is_async() const override { return false; } private: std::string title; }; diff --git a/plugins/Info.hpp b/plugins/Info.hpp index 4ab39f5..af62282 100644 --- a/plugins/Info.hpp +++ b/plugins/Info.hpp @@ -8,7 +8,7 @@ namespace QuickMedia { InfoPage(Program *program) : Page(program) {} const char* get_title() const override { return "Info"; } PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - bool submit_is_async() override { return false; } + bool submit_is_async() const override { return false; } static std::shared_ptr add_url(const std::string &url); static std::shared_ptr add_reverse_image_search(const std::string &image_url); diff --git a/plugins/MangaCombined.hpp b/plugins/MangaCombined.hpp index dafc884..39a143c 100644 --- a/plugins/MangaCombined.hpp +++ b/plugins/MangaCombined.hpp @@ -22,7 +22,6 @@ namespace QuickMedia { SearchResult search(const std::string &str, BodyItems &result_items) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - sf::Vector2i get_thumbnail_max_size() override { return sf::Vector2i(101, 141); }; void cancel_operation() override; private: std::vector search_pages; diff --git a/plugins/MangaGeneric.hpp b/plugins/MangaGeneric.hpp index dcd3544..2f65762 100644 --- a/plugins/MangaGeneric.hpp +++ b/plugins/MangaGeneric.hpp @@ -113,7 +113,6 @@ namespace QuickMedia { PluginResult get_page(const std::string &url, bool is_post, const std::vector &form_data, BodyItems &result_items); PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - sf::Vector2i get_thumbnail_max_size() override { return sf::Vector2i(101, 141); }; MangaGenericSearchPage& search_handler(const char *search_template, int page_start); MangaGenericSearchPage& search_post_handler(const char *url, std::vector form_data, SearchQueryJsonHandler result_handler); @@ -175,7 +174,6 @@ namespace QuickMedia { const char* get_title() const override { return creator.name.c_str(); } PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; - sf::Vector2i get_thumbnail_max_size() override { return sf::Vector2i(101, 141); }; private: MangaGenericSearchPage *search_page; Creator creator; diff --git a/plugins/Mangadex.hpp b/plugins/Mangadex.hpp index 7497b06..cd81c44 100644 --- a/plugins/Mangadex.hpp +++ b/plugins/Mangadex.hpp @@ -16,7 +16,6 @@ namespace QuickMedia { SearchResult search(const std::string &str, BodyItems &result_items) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - sf::Vector2i get_thumbnail_max_size() override { return sf::Vector2i(101, 141); }; ChapterImageUrls chapter_image_urls; private: diff --git a/plugins/Manganelo.hpp b/plugins/Manganelo.hpp index 7cf3420..62fd9bf 100644 --- a/plugins/Manganelo.hpp +++ b/plugins/Manganelo.hpp @@ -10,7 +10,6 @@ namespace QuickMedia { 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 &result_tabs) override; - sf::Vector2i get_thumbnail_max_size() override { return sf::Vector2i(101, 141); }; }; class ManganeloChaptersPage : public MangaChaptersPage { @@ -28,7 +27,6 @@ namespace QuickMedia { const char* get_title() const override { return creator.name.c_str(); } PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; - sf::Vector2i get_thumbnail_max_size() override { return sf::Vector2i(101, 141); }; private: Creator creator; }; diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index f589db5..5292414 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -319,7 +319,7 @@ namespace QuickMedia { const char* get_title() const override { return title.c_str(); } PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - bool submit_is_async() override { return false; } + bool submit_is_async() const override { return false; } bool clear_search_after_submit() override { return true; } void add_body_item(std::shared_ptr body_item); @@ -349,7 +349,7 @@ namespace QuickMedia { MatrixRoomTagsPage(Program *program, Body *body) : Page(program), body(body) {} const char* get_title() const override { return "Tags"; } PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - bool submit_is_async() override { return false; } + bool submit_is_async() const override { return false; } bool clear_search_after_submit() override { return true; } void add_room_body_item_to_tag(std::shared_ptr body_item, const std::string &tag); @@ -380,7 +380,7 @@ namespace QuickMedia { const char* get_title() const override { return title.c_str(); } PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - bool submit_is_async() override { return false; } + bool submit_is_async() const override { return false; } bool clear_search_after_submit() override { return true; } void add_body_item(std::shared_ptr body_item); @@ -484,7 +484,7 @@ namespace QuickMedia { PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; PluginResult lazy_fetch(BodyItems &result_items) override; bool is_ready() override; - bool submit_is_async() override { return false; } + bool submit_is_async() const override { return false; } bool clear_search_after_submit() override { return true; } void add_notification(MatrixNotification notification); diff --git a/plugins/MediaGeneric.hpp b/plugins/MediaGeneric.hpp index 8885db2..fce0e97 100644 --- a/plugins/MediaGeneric.hpp +++ b/plugins/MediaGeneric.hpp @@ -40,7 +40,6 @@ namespace QuickMedia { SearchResult search(const std::string &str, BodyItems &result_items) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - sf::Vector2i get_thumbnail_max_size() override { return thumbnail_max_size; }; PluginResult get_related_media(const std::string &url, BodyItems &result_items); diff --git a/plugins/MyAnimeList.hpp b/plugins/MyAnimeList.hpp new file mode 100644 index 0000000..c88e94f --- /dev/null +++ b/plugins/MyAnimeList.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include "Page.hpp" + +namespace QuickMedia { + class MyAnimeListSearchPage : public Page { + public: + MyAnimeListSearchPage(Program *program) : Page(program) {} + const char* get_title() const override { return "Search for anime or manga"; } + 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 &result_tabs) override; + }; + + class MyAnimeListDetailsPage : public LazyFetchPage { + public: + MyAnimeListDetailsPage(Program *program, std::string url) : LazyFetchPage(program), url(std::move(url)) {} + const char* get_title() const override { return "Details"; } + bool submit_is_async() const override { return false; } + PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult lazy_fetch(BodyItems &result_items) override; + private: + std::string url; + }; + + class MyAnimeListRecommendationsPage : public LazyFetchPage { + public: + MyAnimeListRecommendationsPage(Program *program, std::string url) : LazyFetchPage(program), url(std::move(url)) {} + const char* get_title() const override { return "Recommendations"; } + bool submit_is_async() const override { return false; } + PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult lazy_fetch(BodyItems &result_items) override; + private: + std::string url; + }; +} \ No newline at end of file diff --git a/plugins/NyaaSi.hpp b/plugins/NyaaSi.hpp index 6f161ac..f113544 100644 --- a/plugins/NyaaSi.hpp +++ b/plugins/NyaaSi.hpp @@ -54,7 +54,7 @@ namespace QuickMedia { NyaaSiSortOrderPage(Program *program, Body *body, NyaaSiSearchPage *search_page) : Page(program), body(body), search_page(search_page) {} const char* get_title() const override { return "Sort order"; } PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - bool submit_is_async() override { return false; } + bool submit_is_async() const override { return false; } private: Body *body; NyaaSiSearchPage *search_page; @@ -65,6 +65,6 @@ namespace QuickMedia { NyaaSiTorrentPage(Program *program) : Page(program) {} const char* get_title() const override { return "Torrent"; } PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; - bool submit_is_async() override { return false; } + bool submit_is_async() const override { return false; } }; } \ No newline at end of file diff --git a/plugins/Page.hpp b/plugins/Page.hpp index 9d5bade..8d033e1 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -41,7 +41,7 @@ namespace QuickMedia { return PluginResult::ERR; } // Override and return false to make submit run in the main (ui) thread - virtual bool submit_is_async() { return true; } + virtual bool submit_is_async() const { return true; } virtual bool clear_search_after_submit() { return false; } virtual PluginResult submit_suggestion(const std::string &title, const std::string &url, BodyItems &result_items) { (void)title; @@ -73,8 +73,6 @@ namespace QuickMedia { std::unique_ptr create_search_bar(const std::string &placeholder_text, int search_delay); bool load_manga_content_storage(const char *service_name, const std::string &manga_title, const std::string &manga_id); - - virtual sf::Vector2i get_thumbnail_max_size() { return sf::Vector2i(250, 141); }; Program *program; std::shared_ptr submit_body_item; // TODO: Remove this -- cgit v1.2.3