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
|
#pragma once
#include "Page.hpp"
namespace QuickMedia {
enum class AniListMediaType {
ANIME,
MANGA
};
class AniListSearchPage : public Page {
public:
AniListSearchPage(Program *program, AniListMediaType media_type) : Page(program), media_type(media_type) {}
const char* get_title() const override { return media_type == AniListMediaType::ANIME ? "Search for anime" : "Search for manga"; }
bool search_is_filter() override { return false; }
bool submit_is_async() const override { return false; }
SearchResult search(const std::string &str, BodyItems &result_items) override;
PluginResult submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) override;
PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override;
private:
SearchResult search_page(const std::string &str, int page, BodyItems &result_items);
private:
AniListMediaType media_type;
};
class AniListRelatedPage : public LazyFetchPage {
public:
AniListRelatedPage(Program *program, std::string id) : LazyFetchPage(program), id(std::move(id)) {}
const char* get_title() const override { return "Related"; }
bool submit_is_async() const override { return false; }
PluginResult submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) override;
PluginResult lazy_fetch(BodyItems &result_items) override;
private:
std::string id;
};
class AniListDetailsPage : public LazyFetchPage {
public:
AniListDetailsPage(Program *program, std::string id) : LazyFetchPage(program), id(std::move(id)) {}
const char* get_title() const override { return "Details"; }
bool submit_is_async() const override { return false; }
PluginResult submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) override;
PluginResult lazy_fetch(BodyItems &result_items) override;
private:
std::string id;
};
class AniListRecommendationsPage : public LazyFetchPage {
public:
AniListRecommendationsPage(Program *program, std::string id) : LazyFetchPage(program), id(std::move(id)) {}
const char* get_title() const override { return "Recommendations"; }
bool submit_is_async() const override { return false; }
PluginResult submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) override;
PluginResult lazy_fetch(BodyItems &result_items) override;
PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override;
private:
std::string id;
};
}
|