aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MangaGeneric.hpp25
-rw-r--r--plugins/Matrix.hpp3
-rw-r--r--plugins/Page.hpp2
-rw-r--r--plugins/Soundcloud.hpp9
4 files changed, 35 insertions, 4 deletions
diff --git a/plugins/MangaGeneric.hpp b/plugins/MangaGeneric.hpp
index 98d06d8..a03756d 100644
--- a/plugins/MangaGeneric.hpp
+++ b/plugins/MangaGeneric.hpp
@@ -23,13 +23,19 @@ namespace QuickMedia {
const char *field_name = nullptr;
};
- // If |field_contains| is null, then any matching query is added. If |field_name| is "text", then the inner text is used.
struct ThumbnailQuery {
const char *html_query = nullptr;
const char *field_name = nullptr;
const char *field_contains = nullptr;
};
+ struct AuthorsQuery {
+ const char *html_query = nullptr;
+ const char *title_field = nullptr;
+ const char *url_field = nullptr;
+ const char *url_contains = nullptr;
+ };
+
struct ListChaptersQuery {
const char *html_query = nullptr;
const char *title_field = nullptr;
@@ -92,6 +98,7 @@ namespace QuickMedia {
const char* get_title() const override { return "All"; }
bool search_is_filter() override { return false; }
SearchResult search(const std::string &str, BodyItems &result_items) override;
+ PluginResult get_page(const std::string &url, BodyItems &result_items);
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); };
@@ -106,6 +113,9 @@ namespace QuickMedia {
MangaGenericSearchPage& description_handler(std::vector<DescriptionQuery> queries);
// This is optional.
MangaGenericSearchPage& thumbnail_handler(std::vector<ThumbnailQuery> queries);
+ // If |url_contains| is null, then any matching query is added. If |title_field| is "text", then the inner text is used.
+ // This is optional.
+ MangaGenericSearchPage& authors_handler(const char *html_query, const char *title_field, const char *url_field, const char *url_contains);
// If |url_contains| is null, then any matching query is added. If |title_field| is "text", then the inner text is used.
// This is required.
@@ -141,6 +151,7 @@ namespace QuickMedia {
std::vector<TextQuery> text_queries;
std::vector<DescriptionQuery> description_queries;
std::vector<ThumbnailQuery> thumbnail_queries;
+ AuthorsQuery authors_query;
ListChaptersQuery list_chapters_query;
ListPageQuery list_page_query;
MangaIdExtractor manga_id_extractor;
@@ -162,6 +173,18 @@ namespace QuickMedia {
bool fail_on_http_error;
};
+ class MangaGenericCreatorPage : public LazyFetchPage {
+ public:
+ MangaGenericCreatorPage(Program *program, MangaGenericSearchPage *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 lazy_fetch(BodyItems &result_items) override;
+ sf::Vector2i get_thumbnail_max_size() override { return sf::Vector2i(101, 141); };
+ private:
+ MangaGenericSearchPage *search_page;
+ Creator creator;
+ };
+
class MangaGenericImagesPage : public MangaImagesPage {
public:
MangaGenericImagesPage(Program *program, std::string manga_name, std::string chapter_name, std::string url, const char *service_name, const std::string &website_url, const ListPageQuery *list_page_query, bool fail_on_http_error) :
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp
index 0659983..f76d70d 100644
--- a/plugins/Matrix.hpp
+++ b/plugins/Matrix.hpp
@@ -477,7 +477,8 @@ namespace QuickMedia {
class Matrix {
public:
- void start_sync(MatrixDelegate *delegate, bool &cached);
+ // TODO: Make this return the Matrix object instead, to force users to call start_sync
+ bool start_sync(MatrixDelegate *delegate, bool &cached);
void stop_sync();
bool is_initial_sync_finished() const;
// Returns true if initial sync failed, and |err_msg| is set to the error reason in that case
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index 5c0a558..6599fe4 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -89,6 +89,8 @@ namespace QuickMedia {
virtual bool search_is_filter() override { return true; }
bool is_lazy_fetch_page() const override { return true; }
virtual PluginResult lazy_fetch(BodyItems &result_items) = 0;
+ // If this returns true then |lazy_fetch| is not meant to return results but async background load the page. This can be used to fetch API keys for example
+ virtual bool lazy_fetch_is_loader() { return false; }
};
class RelatedVideosPage : public Page {
diff --git a/plugins/Soundcloud.hpp b/plugins/Soundcloud.hpp
index e04d409..bb23efb 100644
--- a/plugins/Soundcloud.hpp
+++ b/plugins/Soundcloud.hpp
@@ -7,17 +7,22 @@ namespace QuickMedia {
public:
SoundcloudPage(Program *program) : Page(program) {}
virtual ~SoundcloudPage() = default;
+ virtual const char* get_title() const override { return ""; }
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
};
- class SoundcloudSearchPage : public SoundcloudPage {
+ class SoundcloudSearchPage : public LazyFetchPage {
public:
- SoundcloudSearchPage(Program *program) : SoundcloudPage(program) {}
+ SoundcloudSearchPage(Program *program) : LazyFetchPage(program), submit_page(program) {}
const char* get_title() const override { return "Search"; }
bool search_is_filter() override { return false; }
+ PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
SearchResult search(const std::string &str, BodyItems &result_items) override;
PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override;
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+ bool lazy_fetch_is_loader() override { return true; }
private:
+ SoundcloudPage submit_page;
std::string query_urn;
};