aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Fourchan.hpp18
-rw-r--r--plugins/Plugin.hpp22
2 files changed, 40 insertions, 0 deletions
diff --git a/plugins/Fourchan.hpp b/plugins/Fourchan.hpp
new file mode 100644
index 0000000..d6b482b
--- /dev/null
+++ b/plugins/Fourchan.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "Plugin.hpp"
+
+namespace QuickMedia {
+ class Fourchan : public Plugin {
+ public:
+ PluginResult get_front_page(BodyItems &result_items) override;
+ SearchResult search(const std::string &url, BodyItems &result_items) override;
+ SuggestionResult update_search_suggestions(const std::string &text, BodyItems &result_items) override;
+ PluginResult get_content_list(const std::string &url, BodyItems &result_items) override;
+ PluginResult get_content_details(const std::string &list_url, const std::string &url, BodyItems &result_items) override;
+ bool search_suggestions_has_thumbnails() const override { return false; }
+ bool search_results_has_thumbnails() const override { return false; }
+ int get_search_delay() const override { return 150; }
+ Page get_page_after_search() const override { return Page::CONTENT_LIST; }
+ };
+} \ No newline at end of file
diff --git a/plugins/Plugin.hpp b/plugins/Plugin.hpp
index a999d36..d5802af 100644
--- a/plugins/Plugin.hpp
+++ b/plugins/Plugin.hpp
@@ -7,6 +7,12 @@
#include <memory>
namespace QuickMedia {
+ enum class PluginResult {
+ OK,
+ ERR,
+ NET_ERR
+ };
+
enum class SearchResult {
OK,
ERR,
@@ -39,14 +45,30 @@ namespace QuickMedia {
DownloadResult download_to_string(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args = {});
std::string strip(const std::string &str);
+ void string_replace_all(std::string &str, const std::string &old_str, const std::string &new_str);
+ void html_unescape_sequences(std::string &str);
class Plugin {
public:
virtual ~Plugin() = default;
+ virtual PluginResult get_front_page(BodyItems &result_items) {
+ (void)result_items; return PluginResult::OK;
+ }
virtual SearchResult search(const std::string &text, BodyItems &result_items);
virtual SuggestionResult update_search_suggestions(const std::string &text, BodyItems &result_items);
virtual BodyItems get_related_media(const std::string &url);
+ virtual PluginResult get_content_list(const std::string &url, BodyItems &result_items) {
+ (void)url;
+ (void)result_items;
+ return PluginResult::OK;
+ }
+ virtual PluginResult get_content_details(const std::string &list_url, const std::string &url, BodyItems &result_items) {
+ (void)list_url;
+ (void)url;
+ (void)result_items;
+ return PluginResult::OK;
+ }
virtual bool search_suggestions_has_thumbnails() const = 0;
virtual bool search_results_has_thumbnails() const = 0;
virtual int get_search_delay() const = 0;