aboutsummaryrefslogtreecommitdiff
path: root/plugins/Peertube.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Peertube.hpp')
-rw-r--r--plugins/Peertube.hpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/plugins/Peertube.hpp b/plugins/Peertube.hpp
new file mode 100644
index 0000000..833cb5f
--- /dev/null
+++ b/plugins/Peertube.hpp
@@ -0,0 +1,92 @@
+#pragma once
+
+#include "Page.hpp"
+
+namespace QuickMedia {
+ class PeertubeInstanceSelectionPage : public LazyFetchPage {
+ public:
+ PeertubeInstanceSelectionPage(Program *program) : LazyFetchPage(program) {}
+ const char* get_title() const override { return "Select instance"; }
+ bool allow_submit_no_selection() const override { return true; }
+ PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+ };
+
+ class PeertubeSearchPage : public LazyFetchPage {
+ public:
+ enum class SearchType {
+ VIDEO_CHANNELS,
+ VIDEO_PLAYLISTS,
+ VIDEOS
+ };
+
+ PeertubeSearchPage(Program *program, const std::string &server);
+ const char* get_title() const override { return "Search"; }
+ bool search_is_filter() override { return false; }
+ // Fetches local videos if |str| is empty
+ SearchResult search(const std::string &str, BodyItems &result_items) override;
+ 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;
+ // Fetches all local videos
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+ private:
+ PluginResult get_local_videos(int page, BodyItems &result_items);
+ PluginResult get_page_by_type(SearchType search_type, const std::string &str, int page, int count, BodyItems &result_items);
+ private:
+ std::string server;
+ };
+
+ class PeertubeChannelPage : public LazyFetchPage {
+ public:
+ PeertubeChannelPage(Program *program, const std::string &server, std::string display_name, std::string name) :
+ LazyFetchPage(program), server(server), name(std::move(name)), title(std::move(display_name)) {}
+ 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;
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+ private:
+ std::string server;
+ std::string name;
+ std::string title;
+ };
+
+ class PeertubePlaylistPage : public LazyFetchPage {
+ public:
+ PeertubePlaylistPage(Program *program, const std::string &server, std::string display_name, std::string uuid) :
+ LazyFetchPage(program), server(server), uuid(std::move(uuid)), title(std::move(display_name)) {}
+ 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;
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+ private:
+ std::string server;
+ std::string uuid;
+ std::string title;
+ };
+
+ class PeertubeVideoPage : public VideoPage {
+ public:
+ struct VideoSource {
+ std::string url;
+ int resolution; // 720p = 720. 0 = no resolution found
+ };
+
+ PeertubeVideoPage(Program *program, std::string server, std::string url, bool autoplay_next) : VideoPage(program, std::move(url)), server(server), autoplay_next(autoplay_next) {}
+ const char* get_title() const override { return ""; }
+ //BodyItems get_related_media(const std::string &url) override;
+ //bool create_search_page(Program *program, Tab &tab) override;
+ std::unique_ptr<Page> create_comments_page(Program *program) override;
+ std::unique_ptr<RelatedVideosPage> create_related_videos_page(Program *program) override;
+ std::unique_ptr<Page> create_channels_page(Program *program, const std::string &channel_url) override;
+ std::string get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) override;
+ std::string get_audio_url(std::string &ext) override;
+ PluginResult load(std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters, std::string &err_str) override;
+ bool autoplay_next_item() override { return autoplay_next; }
+ //void mark_watched() override;
+ //void get_subtitles(SubtitleData &subtitle_data) override;
+ private:
+ std::string server;
+ std::vector<VideoSource> video_sources;
+ bool autoplay_next;
+ };
+}