aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-21 21:59:07 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-21 21:59:07 +0200
commit58f8ddf56649a3342b500b8526f1cee2593b4562 (patch)
treefac5741d29a4bf8cdca324f53dfb15434f51b9d9 /plugins
parent522ccf3be6e17ea031a702720cea2a2e6c9f2e07 (diff)
Fix mangadex navigate to previous/next page using same images as the previous chapter
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Mangadex.hpp15
1 files changed, 12 insertions, 3 deletions
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<int> &manga_ids, std::vector<std::pair<int, std::string>> &new_manga_ids);
+ using ChapterImageUrls = std::unordered_map<std::string, std::vector<std::string>>;
+
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<Tab> &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<Tab> &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<std::string> 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<std::string> image_urls;
+ ImageResult get_image_urls_for_chapter(const std::string &url);
+ private:
+ MangadexSearchPage *search_page;
};
} \ No newline at end of file