diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/MediaGeneric.hpp | 2 | ||||
-rw-r--r-- | plugins/Page.hpp | 11 | ||||
-rw-r--r-- | plugins/Youtube.hpp | 7 |
3 files changed, 16 insertions, 4 deletions
diff --git a/plugins/MediaGeneric.hpp b/plugins/MediaGeneric.hpp index b1f9030..8885db2 100644 --- a/plugins/MediaGeneric.hpp +++ b/plugins/MediaGeneric.hpp @@ -84,7 +84,7 @@ namespace QuickMedia { MediaGenericVideoPage(Program *program, MediaGenericSearchPage *search_page, const std::string &url) : VideoPage(program, url), search_page(search_page) {} const char* get_title() const override { return ""; } BodyItems get_related_media(const std::string &url) override; - std::unique_ptr<Page> create_search_page(Program *program, int &search_delay) override; + bool create_search_page(Program *program, Tab &tab) override; std::unique_ptr<RelatedVideosPage> create_related_videos_page(Program *program) override; std::unique_ptr<Page> create_channels_page(Program*, const std::string&) override { return nullptr; diff --git a/plugins/Page.hpp b/plugins/Page.hpp index c61fd6d..9d5bade 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -29,6 +29,9 @@ namespace QuickMedia { virtual bool search_is_filter() { return true; } // This show be overriden if search_is_filter is overriden to return false virtual SearchResult search(const std::string &str, BodyItems &result_items) { (void)str; (void)result_items; return SearchResult::ERR; } + // If this returns true then |submit_suggestion| is called when submitting the selected item instead of |submit| + // and |submit| is called when submitting the response of |submit_suggestion| + virtual bool search_is_suggestion() { return false; } // Return empty |result_tabs| and PluginResult::OK to do nothing; which is useful for implementing custom actions on item submit virtual PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) { @@ -40,6 +43,12 @@ namespace QuickMedia { // Override and return false to make submit run in the main (ui) thread virtual bool submit_is_async() { return true; } virtual bool clear_search_after_submit() { return false; } + virtual PluginResult submit_suggestion(const std::string &title, const std::string &url, BodyItems &result_items) { + (void)title; + (void)url; + (void)result_items; + return PluginResult::ERR; + } // Note: If pagination is done by fetching the next page until we get to |page|, then the "current page" should be reset everytime |search| is called. // Note: the first page is 0 virtual PluginResult get_page(const std::string &str, int page, BodyItems &result_items) { (void)str; (void)page; (void)result_items; return PluginResult::OK; } @@ -110,7 +119,7 @@ namespace QuickMedia { virtual PageTypez get_type() const override { return PageTypez::VIDEO; } virtual bool autoplay_next_item() { return false; } virtual BodyItems get_related_media(const std::string &url) { (void)url; return {}; } - virtual std::unique_ptr<Page> create_search_page(Program *program, int &search_delay) { (void)program; (void)search_delay; return nullptr; } + virtual bool create_search_page(Program *program, Tab &tab) { (void)program; (void)tab; return false; } virtual std::unique_ptr<Page> create_comments_page(Program *program) { (void)program; return nullptr; } // Return nullptr if the service doesn't support related videos page virtual std::unique_ptr<RelatedVideosPage> create_related_videos_page(Program *program) = 0; diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index 50412de..c7aff93 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -30,17 +30,20 @@ namespace QuickMedia { class YoutubeSearchPage : public LazyFetchPage { public: - YoutubeSearchPage(Program *program) : LazyFetchPage(program) {} + YoutubeSearchPage(Program *program, std::string video_id = "") : LazyFetchPage(program), video_id(std::move(video_id)) {} const char* get_title() const override { return "Search"; } + bool search_is_suggestion() override { return true; } 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; + PluginResult submit_suggestion(const std::string &title, const std::string &url, BodyItems &result_items) override; PluginResult lazy_fetch(BodyItems &result_items) override; bool lazy_fetch_is_loader() override { return true; } private: PluginResult search_get_continuation(const std::string &url, const std::string &continuation_token, BodyItems &result_items); private: + std::string video_id; std::string search_url; std::string continuation_token; int current_page = 0; @@ -138,7 +141,7 @@ namespace QuickMedia { YoutubeVideoPage(Program *program, std::string url); const char* get_title() const override { return ""; } BodyItems get_related_media(const std::string &url) override; - std::unique_ptr<Page> create_search_page(Program *program, int &search_delay) override; + bool create_search_page(Program *program, Tab &tab) override; std::unique_ptr<Page> create_comments_page(Program *program) override; std::unique_ptr<RelatedVideosPage> create_related_videos_page(Program *program) override; std::unique_ptr<Page> create_channels_page(Program *program, const std::string &channel_url) override; |