aboutsummaryrefslogtreecommitdiff
path: root/plugins/Youtube.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-04-28 05:37:15 +0200
committerdec05eba <dec05eba@protonmail.com>2021-04-28 05:37:42 +0200
commit1b7abc7e819d055b3d0ea5be8967a1e381bb5d60 (patch)
tree503e6f67d933119df4512ef7186ed380b393f868 /plugins/Youtube.hpp
parentf045e579e1faa186ca0ebf6e6d1e562fbcd75727 (diff)
Add youtube subscriptions, etc
Diffstat (limited to 'plugins/Youtube.hpp')
-rw-r--r--plugins/Youtube.hpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp
index 4691f04..4be5339 100644
--- a/plugins/Youtube.hpp
+++ b/plugins/Youtube.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "Page.hpp"
+#include "../include/AsyncTask.hpp"
#include <unordered_set>
namespace QuickMedia {
@@ -47,9 +48,9 @@ namespace QuickMedia {
std::string continuation_token;
};
- class YoutubeChannelPage : public LazyFetchPage {
+ class YoutubeChannelPage : public LazyFetchPage, public TrackablePage {
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)) {}
+ YoutubeChannelPage(Program *program, std::string url, std::string continuation_token, std::string title) : LazyFetchPage(program), TrackablePage(title, url), url(url), continuation_token(std::move(continuation_token)), title(title) {}
const char* get_title() const override { return title.c_str(); }
bool search_is_filter() override { return false; }
SearchResult search(const std::string &str, BodyItems &result_items) override;
@@ -57,6 +58,9 @@ namespace QuickMedia {
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
PluginResult lazy_fetch(BodyItems &result_items) override;
+ TrackResult track(const std::string &str) override;
+ bool is_trackable() const override { return true; }
+
std::unordered_set<std::string> added_videos;
private:
PluginResult search_get_continuation(const std::string &url, const std::string &continuation_token, BodyItems &result_items);
@@ -67,6 +71,21 @@ namespace QuickMedia {
int current_page = 0;
};
+ struct YoutubeSubscriptionTaskResult {
+ std::shared_ptr<BodyItem> body_item;
+ time_t timestamp = 0;
+ };
+
+ class YoutubeSubscriptionsPage : public LazyFetchPage {
+ public:
+ YoutubeSubscriptionsPage(Program *program) : LazyFetchPage(program) {}
+ const char* get_title() const override { return "Subscriptions"; }
+ PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+ private:
+ std::array<AsyncTask<std::vector<YoutubeSubscriptionTaskResult>>, 4> subscription_load_tasks; // TODO: Use multiple curl outputs instead?
+ };
+
class YoutubeRelatedVideosPage : public RelatedVideosPage {
public:
YoutubeRelatedVideosPage(Program *program) : RelatedVideosPage(program) {}
@@ -81,7 +100,7 @@ namespace QuickMedia {
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;
+ std::unique_ptr<Page> create_channels_page(Program *program, const std::string &channel_url) override;
std::string get_url() override { return url; }
private:
std::string xsrf_token;