aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-04-30 21:04:47 +0200
committerdec05eba <dec05eba@protonmail.com>2021-04-30 21:18:06 +0200
commit50afa93c577bed3eb9911d141d46f2e0d3ba2572 (patch)
treef910aa9617bca27435325fb72eec36d8e9aea808 /plugins
parent47bb22a4aee886deb54ca432bdb14747bf2e9160 (diff)
Add 4chan file upload
Diffstat (limited to 'plugins')
-rw-r--r--plugins/FileManager.hpp11
-rw-r--r--plugins/Fourchan.hpp6
-rw-r--r--plugins/ImageBoard.hpp11
3 files changed, 19 insertions, 9 deletions
diff --git a/plugins/FileManager.hpp b/plugins/FileManager.hpp
index 38babc1..2e93a8e 100644
--- a/plugins/FileManager.hpp
+++ b/plugins/FileManager.hpp
@@ -4,9 +4,17 @@
#include <filesystem>
namespace QuickMedia {
+ enum FileManagerMimeType {
+ FILE_MANAGER_MIME_TYPE_IMAGE = (1 << 0),
+ FILE_MANAGER_MIME_TYPE_VIDEO = (1 << 1),
+ FILE_MANAGER_MIME_TYPE_OTHER = (1 << 2)
+ };
+
+ static const FileManagerMimeType FILE_MANAGER_MIME_TYPE_ALL = (FileManagerMimeType)(FILE_MANAGER_MIME_TYPE_IMAGE|FILE_MANAGER_MIME_TYPE_VIDEO|FILE_MANAGER_MIME_TYPE_OTHER);
+
class FileManagerPage : public Page {
public:
- FileManagerPage(Program *program) : Page(program), current_dir("/") {}
+ FileManagerPage(Program *program, FileManagerMimeType mime_type = FILE_MANAGER_MIME_TYPE_ALL) : Page(program), current_dir("/"), mime_type(mime_type) {}
const char* get_title() const override { return current_dir.c_str(); }
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
bool is_single_page() const override { return true; }
@@ -15,5 +23,6 @@ namespace QuickMedia {
PluginResult get_files_in_directory(BodyItems &result_items);
private:
std::filesystem::path current_dir;
+ FileManagerMimeType mime_type;
};
} \ No newline at end of file
diff --git a/plugins/Fourchan.hpp b/plugins/Fourchan.hpp
index 903d534..e2b4671 100644
--- a/plugins/Fourchan.hpp
+++ b/plugins/Fourchan.hpp
@@ -23,16 +23,14 @@ namespace QuickMedia {
const std::string title;
const std::string board_id;
- private:
- std::vector<std::string> cached_media_urls;
};
class FourchanThreadPage : public ImageBoardThreadPage {
public:
- FourchanThreadPage(Program *program, std::string board_id, std::string thread_id, std::vector<std::string> cached_media_urls) : ImageBoardThreadPage(program, std::move(board_id), std::move(thread_id), std::move(cached_media_urls)) {}
+ FourchanThreadPage(Program *program, std::string board_id, std::string thread_id) : ImageBoardThreadPage(program, std::move(board_id), std::move(thread_id)) {}
PluginResult login(const std::string &token, const std::string &pin, std::string &response_msg) override;
- PostResult post_comment(const std::string &captcha_id, const std::string &comment) override;
+ PostResult post_comment(const std::string &captcha_id, const std::string &comment, const std::string &filepath = "") override;
const std::string& get_pass_id() override;
private:
std::string pass_id;
diff --git a/plugins/ImageBoard.hpp b/plugins/ImageBoard.hpp
index 9d4c123..b37448b 100644
--- a/plugins/ImageBoard.hpp
+++ b/plugins/ImageBoard.hpp
@@ -7,28 +7,31 @@ namespace QuickMedia {
OK,
TRY_AGAIN,
BANNED,
+ //FILE_TOO_LARGE,
+ NO_SUCH_FILE,
+ FILE_TYPE_NOT_ALLOWED,
ERR
};
class ImageBoardThreadPage : public VideoPage {
public:
- ImageBoardThreadPage(Program *program, std::string board_id, std::string thread_id, std::vector<std::string> cached_media_urls) : VideoPage(program), board_id(std::move(board_id)), thread_id(std::move(thread_id)), cached_media_urls(std::move(cached_media_urls)) {}
+ ImageBoardThreadPage(Program *program, std::string board_id, std::string thread_id) : VideoPage(program), board_id(std::move(board_id)), thread_id(std::move(thread_id)) {}
const char* get_title() const override { return ""; }
PageTypez get_type() const override { return PageTypez::IMAGE_BOARD_THREAD; }
- BodyItems get_related_media(const std::string &url, std::string &channel_url) override;
+ bool autoplay_next_item() override { return true; }
std::unique_ptr<RelatedVideosPage> create_related_videos_page(Program *program, const std::string &video_url, const std::string &video_title) override;
std::unique_ptr<Page> create_channels_page(Program*, const std::string&) override {
return nullptr;
}
std::string get_url() override { return video_url; }
virtual PluginResult login(const std::string &token, const std::string &pin, std::string &response_msg);
- virtual PostResult post_comment(const std::string &captcha_id, const std::string &comment) = 0;
+ // If |filepath| is empty then no file is uploaded
+ virtual PostResult post_comment(const std::string &captcha_id, const std::string &comment, const std::string &filepath = "") = 0;
virtual const std::string& get_pass_id();
const std::string board_id;
const std::string thread_id;
- const std::vector<std::string> cached_media_urls;
std::string video_url;
};
} \ No newline at end of file