From 58f8ddf56649a3342b500b8526f1cee2593b4562 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 21 May 2021 21:59:07 +0200 Subject: Fix mangadex navigate to previous/next page using same images as the previous chapter --- plugins/Mangadex.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/Mangadex.hpp b/plugins/Mangadex.hpp index 1bed70c..bd4385b 100644 --- a/plugins/Mangadex.hpp +++ b/plugins/Mangadex.hpp @@ -6,6 +6,8 @@ namespace QuickMedia { PluginResult legacy_mangadex_id_to_new_manga_id(Page *page, const std::vector &manga_ids, std::vector> &new_manga_ids); + using ChapterImageUrls = std::unordered_map>; + class MangadexSearchPage : public Page { public: MangadexSearchPage(Program *program) : Page(program) {} @@ -15,6 +17,8 @@ namespace QuickMedia { 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: SearchResult search(const std::string &str, int page, BodyItems &result_items); bool get_rememberme_token(std::string &rememberme_token); @@ -23,22 +27,27 @@ namespace QuickMedia { class MangadexChaptersPage : public MangaChaptersPage { public: - MangadexChaptersPage(Program *program, std::string manga_name, std::string manga_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)) {} + MangadexChaptersPage(Program *program, MangadexSearchPage *search_page, std::string manga_name, std::string manga_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)), search_page(search_page) {} PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; protected: bool extract_id_from_url(const std::string &url, std::string &manga_id) const override; const char* get_service_name() const override { return "mangadex"; } + private: + MangadexSearchPage *search_page; }; class MangadexImagesPage : public MangaImagesPage { public: - MangadexImagesPage(Program *program, std::string manga_name, std::string chapter_name, std::string url, std::vector image_urls) : MangaImagesPage(program, std::move(manga_name), std::move(chapter_name), std::move(url)), image_urls(std::move(image_urls)) {} + MangadexImagesPage(Program *program, MangadexSearchPage *search_page, std::string manga_name, std::string chapter_id, std::string chapter_name) : + MangaImagesPage(program, std::move(manga_name), std::move(chapter_name), std::move(chapter_id)), search_page(search_page) {} ImageResult get_number_of_images(int &num_images) override; ImageResult for_each_page_in_chapter(PageCallback callback) override; const char* get_service_name() const override { return "mangadex"; } const char* get_website_url() const override { return "https://mangadex.org/"; } private: - std::vector image_urls; + ImageResult get_image_urls_for_chapter(const std::string &url); + private: + MangadexSearchPage *search_page; }; } \ No newline at end of file -- cgit v1.2.3