aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-11 00:42:21 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-11 00:42:21 +0100
commit1f74222bf4cfadead768b095c6b3f8d422ebf84c (patch)
tree39035288edb79852cef6237f0d7ab8ea146cf218 /plugins
parent404ac476a213164a041f0f53be30855df815aa6a (diff)
Add local-manga plugin to read local manga
Diffstat (limited to 'plugins')
-rw-r--r--plugins/LocalManga.hpp61
-rw-r--r--plugins/Manga.hpp2
-rw-r--r--plugins/MangaCombined.hpp5
-rw-r--r--plugins/Page.hpp3
4 files changed, 69 insertions, 2 deletions
diff --git a/plugins/LocalManga.hpp b/plugins/LocalManga.hpp
new file mode 100644
index 0000000..27ee89d
--- /dev/null
+++ b/plugins/LocalManga.hpp
@@ -0,0 +1,61 @@
+#pragma once
+
+#include "Manga.hpp"
+
+namespace QuickMedia {
+ struct LocalMangaPage {
+ Path path;
+ int number;
+ };
+
+ struct LocalMangaChapter {
+ std::string name;
+ std::vector<LocalMangaPage> pages;
+ time_t modified_time_seconds;
+ };
+
+ struct LocalManga {
+ std::string name;
+ std::vector<LocalMangaChapter> chapters;
+ time_t modified_time_seconds;
+ };
+
+ class LocalMangaSearchPage : public LazyFetchPage {
+ public:
+ LocalMangaSearchPage(Program *program, bool standalone) : LazyFetchPage(program), standalone(standalone) {}
+ const char* get_title() const override { return "Search"; }
+ bool search_is_filter() override { return standalone; }
+ SearchResult search(const std::string &str, BodyItems &result_items) override;
+ PluginResult submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) override;
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+ const char* get_bookmark_name() const override { return "local-manga"; }
+ private:
+ std::vector<LocalManga> manga_list;
+ bool standalone;
+ };
+
+ class LocalMangaChaptersPage : public MangaChaptersPage {
+ public:
+ LocalMangaChaptersPage(Program *program, std::string manga_name, std::string manga_url, const std::string &thumbnail_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url), thumbnail_url) {}
+ PluginResult submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) override;
+ const char* get_bookmark_name() const override { return "local-manga"; }
+ protected:
+ bool extract_id_from_url(const std::string &url, std::string &manga_id) const override;
+ const char* get_service_name() const override { return "local-manga"; }
+ };
+
+ class LocalMangaImagesPage : public MangaImagesPage {
+ public:
+ LocalMangaImagesPage(Program *program, std::string manga_name, std::string chapter_name, std::string url, std::string thumbnail_url, std::vector<LocalMangaPage> pages) :
+ MangaImagesPage(program, std::move(manga_name), std::move(chapter_name), std::move(url), std::move(thumbnail_url)), pages(std::move(pages)) {}
+ 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 "local-manga"; }
+ const char* get_website_url() const override { return "localhost"; }
+ bool is_local() override { return true; }
+ private:
+ ImageResult get_image_urls_for_chapter(const std::string &url);
+ private:
+ std::vector<LocalMangaPage> pages;
+ };
+} \ No newline at end of file
diff --git a/plugins/Manga.hpp b/plugins/Manga.hpp
index 7b67e13..bc6b415 100644
--- a/plugins/Manga.hpp
+++ b/plugins/Manga.hpp
@@ -46,6 +46,8 @@ namespace QuickMedia {
virtual const char* get_website_url() const = 0;
+ virtual bool is_local() { return false; }
+
const std::string manga_name;
const std::string thumbnail_url;
protected:
diff --git a/plugins/MangaCombined.hpp b/plugins/MangaCombined.hpp
index 1348b1b..670055f 100644
--- a/plugins/MangaCombined.hpp
+++ b/plugins/MangaCombined.hpp
@@ -10,11 +10,12 @@ namespace QuickMedia {
std::unique_ptr<Page> page;
std::string title;
std::string service_name;
+ bool local_manga = false;
};
using MangaCombinedSearchThread = std::pair<MangaPlugin*, AsyncTask<BodyItems>>;
- class MangaCombinedSearchPage : public Page {
+ class MangaCombinedSearchPage : public LazyFetchPage {
public:
MangaCombinedSearchPage(Program *program, std::vector<MangaPlugin> search_pages);
const char* get_title() const override { return "Search"; }
@@ -22,6 +23,8 @@ namespace QuickMedia {
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 SubmitArgs &args, std::vector<Tab> &result_tabs) override;
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+ bool lazy_fetch_is_loader() override { return true; }
void cancel_operation() override;
private:
std::vector<MangaPlugin> search_pages;
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index 0e904c2..a803725 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -176,7 +176,7 @@ namespace QuickMedia {
class BookmarksPage : public LazyFetchPage {
public:
- BookmarksPage(Program *program, Page *redirect_page) : LazyFetchPage(program), redirect_page(redirect_page) {}
+ BookmarksPage(Program *program, Page *redirect_page, bool local_thumbnail = false) : LazyFetchPage(program), redirect_page(redirect_page), local_thumbnail(local_thumbnail) {}
const char* get_title() const override { return "Bookmarks"; }
PluginResult submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) override;
PluginResult lazy_fetch(BodyItems &result_items) override;
@@ -185,5 +185,6 @@ namespace QuickMedia {
bool is_bookmark_page() const override { return true; }
private:
Page *redirect_page;
+ bool local_thumbnail;
};
} \ No newline at end of file