diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/MediaGeneric.hpp | 17 | ||||
-rw-r--r-- | plugins/Page.hpp | 1 |
2 files changed, 16 insertions, 2 deletions
diff --git a/plugins/MediaGeneric.hpp b/plugins/MediaGeneric.hpp index 3720ba3..684f319 100644 --- a/plugins/MediaGeneric.hpp +++ b/plugins/MediaGeneric.hpp @@ -30,9 +30,11 @@ namespace QuickMedia { std::string thumbnail_url; }; + using MediaVideoUrlCustomHandler = std::function<std::string(const std::string &html_source)>; using MediaRelatedCustomHandler = std::function<std::vector<MediaRelatedItem>(const std::string &html_source)>; class MediaGenericSearchPage : public Page { + friend class MediaGenericVideoPage; public: MediaGenericSearchPage(Program *program, const char *website_url, mgl::vec2i thumbnail_max_size, bool cloudflare_bypass, std::vector<CommandArg> extra_commands = {}); const char* get_title() const override { return "Search"; } @@ -51,6 +53,8 @@ namespace QuickMedia { MediaGenericSearchPage& text_handler(std::vector<MediaTextQuery> queries); // This is optional. MediaGenericSearchPage& thumbnail_handler(std::vector<MediaThumbnailQuery> queries); + // This is optional. Youtube-dl (or yt-dlp) is used instead if this is not used. + MediaGenericSearchPage& video_url_custom_handler(MediaVideoUrlCustomHandler handler); // This is optional. MediaGenericSearchPage& related_media_text_handler(std::vector<MediaTextQuery> queries); @@ -61,13 +65,16 @@ namespace QuickMedia { private: std::string website_url; mgl::vec2i thumbnail_max_size; + MediaSearchQuery search_query; std::vector<MediaTextQuery> text_queries; std::vector<MediaThumbnailQuery> thumbnail_queries; + MediaVideoUrlCustomHandler video_custom_handler = nullptr; + std::vector<MediaTextQuery> related_media_text_queries; std::vector<MediaThumbnailQuery> related_media_thumbnail_queries; MediaRelatedCustomHandler related_custom_handler = nullptr; - bool cloudflare_bypass; + bool cloudflare_bypass = false; std::vector<CommandArg> extra_commands; }; @@ -81,11 +88,17 @@ namespace QuickMedia { class MediaGenericVideoPage : public VideoPage { public: - MediaGenericVideoPage(Program *program, MediaGenericSearchPage *search_page, const std::string &url) : VideoPage(program, url), search_page(search_page) {} + MediaGenericVideoPage(Program *program, MediaGenericSearchPage *search_page, const std::string &url) : + VideoPage(program, url), search_page(search_page) {} 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<Tab> &result_tabs) override; + + std::string get_download_url(int max_height) override; + std::string get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) override; + PluginResult load(std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters, std::string &err_str) override; private: MediaGenericSearchPage *search_page; + std::string video_url; }; }
\ No newline at end of file diff --git a/plugins/Page.hpp b/plugins/Page.hpp index da6405c..e25cb84 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -164,6 +164,7 @@ namespace QuickMedia { // Only used if |get_video_url| sets |has_embedded_audio| to false. // Might do a network request. virtual std::string get_audio_url(std::string &ext) { (void)ext; return ""; } + // Might do a network request virtual std::string url_get_playable_url(const std::string &url) { return url; } virtual bool video_should_be_skipped(const std::string &url) { (void)url; return false; } // This needs to be called before the other functions are called |