From 5d29f22093fd602bc4d8863208e7812c0746e62e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 10 Mar 2021 23:25:09 +0100 Subject: Youtube: add youtube comments to ctrl+r --- plugins/Page.hpp | 1 + plugins/Youtube.hpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'plugins') diff --git a/plugins/Page.hpp b/plugins/Page.hpp index e720f14..44526db 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -101,6 +101,7 @@ namespace QuickMedia { 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; } + virtual std::unique_ptr create_comments_page(Program *program) { (void)program; 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 diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index c0bb429..f8a5d5f 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -21,6 +21,32 @@ namespace QuickMedia { std::unordered_set added_videos; }; + class YoutubeCommentsPage : public LazyFetchPage { + public: + YoutubeCommentsPage(Program *program, const std::string &xsrf_token, const std::string &continuation_token) : LazyFetchPage(program), xsrf_token(xsrf_token), continuation_token(continuation_token) {} + const char* get_title() const override { return "Comments"; } + 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; + private: + int current_page = 0; + std::string xsrf_token; + std::string continuation_token; + }; + + class YoutubeCommentRepliesPage : public LazyFetchPage { + public: + YoutubeCommentRepliesPage(Program *program, const std::string &xsrf_token, const std::string &continuation_token) : LazyFetchPage(program), xsrf_token(xsrf_token), continuation_token(continuation_token) {} + const char* get_title() const override { return "Comment replies"; } + 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; + private: + int current_page = 0; + std::string xsrf_token; + std::string continuation_token; + }; + class YoutubeChannelPage : public LazyFetchPage { public: 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)) {} @@ -53,7 +79,11 @@ namespace QuickMedia { const char* get_title() const override { return ""; } 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_comments_page(Program *program) 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; + private: + std::string xsrf_token; + std::string comments_continuation_token; }; } \ No newline at end of file -- cgit v1.2.3