aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MediaGeneric.hpp85
-rw-r--r--plugins/Pornhub.hpp36
-rw-r--r--plugins/Spankbang.hpp36
3 files changed, 85 insertions, 72 deletions
diff --git a/plugins/MediaGeneric.hpp b/plugins/MediaGeneric.hpp
new file mode 100644
index 0000000..e4048a9
--- /dev/null
+++ b/plugins/MediaGeneric.hpp
@@ -0,0 +1,85 @@
+#pragma once
+
+#include "Page.hpp"
+#include <functional>
+
+namespace QuickMedia {
+ struct MediaSearchQuery {
+ const char *search_template = nullptr;
+ int page_start = 0;
+ };
+
+ // If |url_contains| is null, then any matching query is added. If |title_field| is "text", then the inner text is used.
+ // If |url_field| is null, then the current page is used instead.
+ struct MediaTextQuery {
+ const char *html_query = nullptr;
+ const char *title_field = nullptr;
+ const char *url_field = nullptr;
+ const char *url_contains = nullptr;
+ };
+
+ struct MediaThumbnailQuery {
+ const char *html_query = nullptr;
+ const char *field_name = nullptr;
+ const char *field_contains = nullptr;
+ };
+
+ class MediaGenericSearchPage : public Page {
+ public:
+ MediaGenericSearchPage(Program *program, const char *website_url, sf::Vector2i thumbnail_max_size);
+ 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 &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 thumbnail_max_size; };
+
+ PluginResult get_related_media(const std::string &url, BodyItems &result_items);
+
+ // Add a %s where the search query should be inserted into |search_template| and add a %p where the page number should be inserted, for example:
+ // example.com/search?q=%s&page=%p
+ // This is required.
+ MediaGenericSearchPage& search_handler(const char *search_template, int page_start);
+ // This is required.
+ MediaGenericSearchPage& text_handler(std::vector<MediaTextQuery> queries);
+ // This is optional.
+ MediaGenericSearchPage& thumbnail_handler(std::vector<MediaThumbnailQuery> queries);
+
+ // This is optional.
+ MediaGenericSearchPage& related_media_text_handler(std::vector<MediaTextQuery> queries);
+ // This is optional.
+ MediaGenericSearchPage& related_media_thumbnail_handler(std::vector<MediaThumbnailQuery> queries);
+ private:
+ std::string website_url;
+ sf::Vector2i thumbnail_max_size;
+ MediaSearchQuery search_query;
+ std::vector<MediaTextQuery> text_queries;
+ std::vector<MediaThumbnailQuery> thumbnail_queries;
+ std::vector<MediaTextQuery> related_media_text_queries;
+ std::vector<MediaThumbnailQuery> related_media_thumbnail_queries;
+ };
+
+ class MediaGenericRelatedPage : public RelatedVideosPage {
+ public:
+ MediaGenericRelatedPage(Program *program, MediaGenericSearchPage *search_page) : RelatedVideosPage(program), search_page(search_page) {}
+ PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ private:
+ MediaGenericSearchPage *search_page;
+ };
+
+ class MediaGenericVideoPage : public VideoPage {
+ public:
+ MediaGenericVideoPage(Program *program, MediaGenericSearchPage *search_page, const std::string &url) : VideoPage(program), search_page(search_page), url(url) {}
+ const char* get_title() const override { return ""; }
+ BodyItems get_related_media(const std::string &url, std::string &channel_url) override;
+ std::unique_ptr<Page> create_search_page(Program *program, int &search_delay) override;
+ 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 url; }
+ private:
+ MediaGenericSearchPage *search_page;
+ std::string url;
+ };
+} \ No newline at end of file
diff --git a/plugins/Pornhub.hpp b/plugins/Pornhub.hpp
deleted file mode 100644
index 8f6f563..0000000
--- a/plugins/Pornhub.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#pragma once
-
-#include "Page.hpp"
-
-namespace QuickMedia {
- class PornhubSearchPage : public Page {
- public:
- PornhubSearchPage(Program *program) : Page(program) {}
- 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 &str, int page, BodyItems &result_items) override;
- PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
- };
-
- class PornhubRelatedVideosPage : public RelatedVideosPage {
- public:
- PornhubRelatedVideosPage(Program *program) : RelatedVideosPage(program) {}
- PluginResult submit(const std::string&, const std::string&, std::vector<Tab> &result_tabs) override;
- };
-
- class PornhubVideoPage : public VideoPage {
- public:
- PornhubVideoPage(Program *program, const std::string &url) : VideoPage(program), url(url) {}
- const char* get_title() const override { return ""; }
- BodyItems get_related_media(const std::string &url, std::string &channel_url) override;
- std::unique_ptr<Page> create_search_page(Program *program, int &search_delay) override;
- 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 url; }
- private:
- std::string url;
- };
-} \ No newline at end of file
diff --git a/plugins/Spankbang.hpp b/plugins/Spankbang.hpp
deleted file mode 100644
index 06ea509..0000000
--- a/plugins/Spankbang.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#pragma once
-
-#include "Page.hpp"
-
-namespace QuickMedia {
- class SpankbangSearchPage : public Page {
- public:
- SpankbangSearchPage(Program *program) : Page(program) {}
- 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 &str, int page, BodyItems &result_items) override;
- PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
- };
-
- class SpankbangRelatedVideosPage : public RelatedVideosPage {
- public:
- SpankbangRelatedVideosPage(Program *program) : RelatedVideosPage(program) {}
- PluginResult submit(const std::string&, const std::string&, std::vector<Tab> &result_tabs) override;
- };
-
- class SpankbangVideoPage : public VideoPage {
- public:
- SpankbangVideoPage(Program *program, const std::string &url) : VideoPage(program), url(url) {}
- const char* get_title() const override { return ""; }
- BodyItems get_related_media(const std::string &url, std::string &channel_url) override;
- std::unique_ptr<Page> create_search_page(Program *program, int &search_delay) override;
- 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 url; }
- private:
- std::string url;
- };
-} \ No newline at end of file