diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-11-04 01:30:38 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-11-04 01:30:38 +0100 |
commit | b6b972e2dae816a8f0686f4986029a5ed50e592c (patch) | |
tree | b7966625b8ad02628f053a7436c0dd39d8de8abd /plugins/Page.hpp | |
parent | ae6fb457ca385540e0f9b1347ef9c3c84815b16d (diff) |
Add channels page to related videos menu, fix related videos menu broken after video failing to load
Diffstat (limited to 'plugins/Page.hpp')
-rw-r--r-- | plugins/Page.hpp | 29 |
1 files changed, 25 insertions, 4 deletions
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<Tab> &result_tabs) = 0; + virtual PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &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<CommandArg> 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<Page> 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<RelatedVideosPage> 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<LazyFetchPage> create_channels_page(Program *program, const std::string &channel_url) = 0; + }; }
\ No newline at end of file |