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/Youtube.hpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'plugins/Youtube.hpp') diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index e2dd201..1a66e5c 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -21,12 +21,13 @@ namespace QuickMedia { std::unordered_set added_videos; }; - class YoutubeChannelPage : public Page { + class YoutubeChannelPage : public LazyFetchPage { public: - YoutubeChannelPage(Program *program, std::string url, std::string continuation_token, std::string title) : Page(program), url(std::move(url)), continuation_token(std::move(continuation_token)), title(std::move(title)) {} + YoutubeChannelPage(Program *program, std::string url, std::string continuation_token, std::string title) : LazyFetchPage(program), url(std::move(url)), continuation_token(std::move(continuation_token)), title(std::move(title)) {} const char* get_title() const override { return title.c_str(); } 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 &result_tabs) override; + PluginResult lazy_fetch(BodyItems &result_items) override; std::unordered_set added_videos; private: @@ -38,17 +39,19 @@ namespace QuickMedia { int current_page = 0; }; - class YoutubeVideoPage : public Page { + class YoutubeRelatedVideosPage : public RelatedVideosPage { public: - YoutubeVideoPage(Program *program) : Page(program) {} + YoutubeRelatedVideosPage(Program *program) : RelatedVideosPage(program) {} + PluginResult submit(const std::string&, const std::string&, std::vector &result_tabs) override; + }; + + class YoutubeVideoPage : public VideoPage { + public: + YoutubeVideoPage(Program *program) : VideoPage(program) {} const char* get_title() const override { return ""; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override { - (void)title; - (void)url; - (void)result_tabs; - return PluginResult::ERR; - } - BodyItems get_related_media(const std::string &url) override; - PageTypez get_type() const override { return PageTypez::VIDEO; } + BodyItems get_related_media(const std::string &url, std::string &channel_url) override; + std::unique_ptr create_search_page(Program *program, int &search_delay) override; + std::unique_ptr create_related_videos_page(Program *program, const std::string &video_url, const std::string &video_title) override; + std::unique_ptr create_channels_page(Program *program, const std::string &channel_url) override; }; } \ No newline at end of file -- cgit v1.2.3