aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-03-10 23:25:09 +0100
committerdec05eba <dec05eba@protonmail.com>2021-03-10 23:27:28 +0100
commit5d29f22093fd602bc4d8863208e7812c0746e62e (patch)
tree844ee610b45880873e7afe17cb563f35e8982af5 /plugins
parent1fe31ba2e244d9ae26d1f8d00f411713d2eaacf7 (diff)
Youtube: add youtube comments to ctrl+r
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Page.hpp1
-rw-r--r--plugins/Youtube.hpp30
2 files changed, 31 insertions, 0 deletions
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<Page> create_search_page(Program *program, int &search_delay) { (void)program; (void)search_delay; return nullptr; }
+ 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, 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<std::string> 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<Tab> &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<Tab> &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<Page> create_search_page(Program *program, int &search_delay) override;
+ std::unique_ptr<Page> create_comments_page(Program *program) override;
std::unique_ptr<RelatedVideosPage> create_related_videos_page(Program *program, const std::string &video_url, const std::string &video_title) override;
std::unique_ptr<LazyFetchPage> 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