From 89e018c4f24a03a9436024539d10d2b058d6e956 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 29 Oct 2023 14:22:24 +0100 Subject: Youtube: support playlists --- plugins/Youtube.hpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index 0393739..22cb9e5 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -106,7 +106,8 @@ namespace QuickMedia { enum class Type { VIDEOS, SHORTS, - LIVE + LIVE, + PLAYLISTS }; static void create_each_type(Program *program, std::string url, std::string continuation_token, std::string title, std::vector &tabs); @@ -154,9 +155,21 @@ namespace QuickMedia { PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; }; + class YoutubePlaylistPage : public LazyFetchPage { + public: + YoutubePlaylistPage(Program *program, std::string url, std::string title) : + LazyFetchPage(program), url(std::move(url)), title(std::move(title)) {} + const char* get_title() const override { return title.c_str(); } + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; + PluginResult lazy_fetch(BodyItems &result_items) override; + private: + std::string url; + std::string title; + }; + class YoutubeVideoPage : public VideoPage { public: - YoutubeVideoPage(Program *program, std::string url, bool autoplay = true); + YoutubeVideoPage(Program *program, std::string url, bool autoplay = true, bool autoplay_next_item = false); const char* get_title() const override { return ""; } BodyItems get_related_media(const std::string &url) override; PluginResult get_related_pages(const BodyItems &related_videos, const std::string &channel_url, std::vector &result_tabs) override; @@ -170,6 +183,7 @@ namespace QuickMedia { void mark_watched() override; void get_subtitles(SubtitleData &subtitle_data) override; void set_watch_progress(int64_t time_pos_sec, int64_t duration_sec) override; + bool autoplay_next_item() override { return goto_next_item; } private: PluginResult parse_video_response(const Json::Value &json_root, std::string &title, std::string &channel_url, std::vector &chapters, std::string &err_str); void parse_format(const Json::Value &format_json, bool is_adaptive); @@ -186,5 +200,6 @@ namespace QuickMedia { std::string watchtime_url; std::string tracking_url; YoutubeVideoDetails video_details; + bool goto_next_item; }; } -- cgit v1.2.3