aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-10-12 08:10:32 +0200
committerdec05eba <dec05eba@protonmail.com>2019-10-12 08:10:35 +0200
commit0fda98b233ae0f44b1f0a8691958087619b243e1 (patch)
treebd3187a03b18b7a4765e57801e932401af63f542 /plugins
parent589bc5b1694a355ad92b17048f5b5ee9b45d24d2 (diff)
Start on 4chan, go to previous/next chapter when reaching beginning/end
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;