aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-12 15:33:49 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-12 15:33:49 +0200
commita9d69f57a0cd4f9cccff07b2890a860695d1e7ed (patch)
treef03e747dc6a0f52fbbef3772437ddf230a05c721 /plugins
parentde8682ce581cdc3f0886e3edf89b430a7215aea1 (diff)
Mangadex: add author/artist tabs for manga, optimize search (covers)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Mangadex.hpp26
-rw-r--r--plugins/Page.hpp4
2 files changed, 20 insertions, 10 deletions
diff --git a/plugins/Mangadex.hpp b/plugins/Mangadex.hpp
index beceddb..67f68b7 100644
--- a/plugins/Mangadex.hpp
+++ b/plugins/Mangadex.hpp
@@ -17,19 +17,15 @@ 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;
const char* get_bookmark_name() const override { return "mangadex"; }
-
- ChapterImageUrls chapter_image_urls;
private:
- // Cover id should be set in the body items thumbnail url
- PluginResult get_cover_urls(BodyItems &body_items);
- SearchResult search(const std::string &str, int page, BodyItems &result_items);
bool get_rememberme_token(std::string &rememberme_token);
std::optional<std::string> rememberme_token;
};
class MangadexChaptersPage : public MangaChaptersPage {
public:
- 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) {}
+ MangadexChaptersPage(Program *program, MangadexSearchPage *search_page, std::string manga_name, std::string manga_url, ChapterImageUrls chapter_image_urls) :
+ MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)), search_page(search_page), chapter_image_urls(std::move(chapter_image_urls)) {}
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;
const char* get_bookmark_name() const override { return "mangadex"; }
@@ -38,12 +34,25 @@ namespace QuickMedia {
const char* get_service_name() const override { return "mangadex"; }
private:
MangadexSearchPage *search_page;
+ ChapterImageUrls chapter_image_urls;
+ };
+
+ class MangadexCreatorPage : public LazyFetchPage {
+ public:
+ MangadexCreatorPage(Program *program, MangadexSearchPage *search_page, Creator creator) : LazyFetchPage(program), search_page(search_page), creator(std::move(creator)) {}
+ const char* get_title() const override { return creator.name.c_str(); }
+ 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;
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+ private:
+ MangadexSearchPage *search_page;
+ Creator creator;
};
class MangadexImagesPage : public MangaImagesPage {
public:
- 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) {}
+ MangadexImagesPage(Program *program, MangadexSearchPage *search_page, std::string manga_name, std::string chapter_id, std::string chapter_name, ChapterImageUrls *chapter_image_url_templates) :
+ MangaImagesPage(program, std::move(manga_name), std::move(chapter_name), std::move(chapter_id)), search_page(search_page), chapter_image_url_templates(chapter_image_url_templates) {}
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"; }
@@ -52,5 +61,6 @@ namespace QuickMedia {
ImageResult get_image_urls_for_chapter(const std::string &url);
private:
MangadexSearchPage *search_page;
+ ChapterImageUrls *chapter_image_url_templates;
};
} \ No newline at end of file
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index 29fce27..d5daa3d 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -11,7 +11,7 @@ namespace QuickMedia {
class Program;
constexpr int SEARCH_DELAY_FILTER = 50;
- // TODO: Remove to PageType when the other PageType is removed
+ // TODO: Rename to PageType when the other PageType is removed
enum class PageTypez {
REGULAR,
MANGA_IMAGES,
@@ -50,7 +50,7 @@ namespace QuickMedia {
return PluginResult::ERR;
}
// Note: If pagination is done by fetching the next page until we get to |page|, then the "current page" should be reset everytime |search| is called.
- // Note: the first page fetched is 1 (search page is 0)
+ // Note: the first page fetched is 1 (search/lazy fetch page is 0)
virtual PluginResult get_page(const std::string &str, int page, BodyItems &result_items) { (void)str; (void)page; (void)result_items; return PluginResult::OK; }
DownloadResult download_json(Json::Value &result, const std::string &url, std::vector<CommandArg> additional_args, bool use_browser_useragent = false, std::string *err_msg = nullptr);