1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#pragma once
#include "Manga.hpp"
#include <functional>
#include <optional>
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) {}
const char* get_title() const override { return "Search"; }
bool search_is_filter() override { return false; }
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<Tab> &result_tabs) override;
const char* get_bookmark_name() const override { return "mangadex"; }
private:
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, 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"; }
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;
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, 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"; }
const char* get_website_url() const override { return "https://mangadex.org/"; }
private:
ImageResult get_image_urls_for_chapter(const std::string &url);
private:
MangadexSearchPage *search_page;
ChapterImageUrls *chapter_image_url_templates;
};
}
|