From 1b7abc7e819d055b3d0ea5be8967a1e381bb5d60 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 28 Apr 2021 05:37:15 +0200 Subject: Add youtube subscriptions, etc --- plugins/Youtube.hpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'plugins/Youtube.hpp') 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 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 &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 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 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 &result_tabs) override; + PluginResult lazy_fetch(BodyItems &result_items) override; + private: + std::array>, 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 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; + std::unique_ptr create_channels_page(Program *program, const std::string &channel_url) override; std::string get_url() override { return url; } private: std::string xsrf_token; -- cgit v1.2.3