From b6b972e2dae816a8f0686f4986029a5ed50e592c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 4 Nov 2020 01:30:38 +0100 Subject: Add channels page to related videos menu, fix related videos menu broken after video failing to load --- plugins/Page.hpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'plugins/Page.hpp') diff --git a/plugins/Page.hpp b/plugins/Page.hpp index 5f5af60..28c2bd6 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -29,14 +29,16 @@ namespace QuickMedia { virtual SearchResult search(const std::string &str, BodyItems &result_items) { (void)str; (void)result_items; return SearchResult::ERR; } // 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 &result_tabs) = 0; + virtual PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) { + (void)title; + (void)url; + (void)result_tabs; + 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; } - // TODO: Move to a subclass called VideoPage - virtual BodyItems get_related_media(const std::string &url); - DownloadResult download_json(Json::Value &result, const std::string &url, std::vector additional_args, bool use_browser_useragent = false, std::string *err_msg = nullptr); virtual PageTypez get_type() const { return PageTypez::REGULAR; } @@ -81,7 +83,26 @@ namespace QuickMedia { class LazyFetchPage : public Page { public: LazyFetchPage(Program *program) : Page(program) {} + bool search_is_filter() override { return true; } bool is_lazy_fetch_page() const override { return true; } virtual PluginResult lazy_fetch(BodyItems &result_items) = 0; }; + + class RelatedVideosPage : public Page { + public: + RelatedVideosPage(Program *program) : Page(program) {} + const char* get_title() const override { return "Related videos"; } + }; + + class VideoPage : public Page { + public: + VideoPage(Program *program) : Page(program) {} + virtual PageTypez get_type() const override { return PageTypez::VIDEO; } + virtual BodyItems get_related_media(const std::string &url, std::string &channel_url) { (void)url; (void)channel_url; return {}; } + virtual std::unique_ptr create_search_page(Program *program, int &search_delay) { (void)program; (void)search_delay; return nullptr; } + // Return nullptr if the service doesn't support related videos page + virtual std::unique_ptr create_related_videos_page(Program *program, const std::string &video_url, const std::string &video_title) = 0; + // Return nullptr if the service doesn't support channels page + virtual std::unique_ptr create_channels_page(Program *program, const std::string &channel_url) = 0; + }; } \ No newline at end of file -- cgit v1.2.3