diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-11-03 20:29:20 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-11-03 20:29:20 +0100 |
commit | ae6fb457ca385540e0f9b1347ef9c3c84815b16d (patch) | |
tree | 67ef2e460062dc21e33269ffa54deb58d57b39b9 /plugins | |
parent | 79a575beddfd23dd3103fdb41a9c5b176ee321f3 (diff) |
Youtube add channel page, fix search pagination (update to correct continuation token)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Page.hpp | 1 | ||||
-rw-r--r-- | plugins/Youtube.hpp | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/plugins/Page.hpp b/plugins/Page.hpp index db11a61..5f5af60 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -34,6 +34,7 @@ namespace QuickMedia { // 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); diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index bdb9c8b..e2dd201 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -1,6 +1,7 @@ #pragma once #include "Page.hpp" +#include <unordered_set> namespace QuickMedia { class YoutubeSearchPage : public Page { @@ -17,6 +18,24 @@ namespace QuickMedia { std::string search_url; std::string continuation_token; int current_page = 0; + std::unordered_set<std::string> added_videos; + }; + + class YoutubeChannelPage : public Page { + 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)) {} + 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<Tab> &result_tabs) override; + + std::unordered_set<std::string> added_videos; + private: + PluginResult search_get_continuation(const std::string &url, const std::string &continuation_token, BodyItems &result_items); + private: + const std::string url; + std::string continuation_token; + const std::string title; + int current_page = 0; }; class YoutubeVideoPage : public Page { |