aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-04 00:06:11 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-04 00:06:11 +0100
commita13c19e31cb033730fa179a90f0bc5bd961bd3dc (patch)
treeee459da17b1baa8a1aba503451231a5075c46c8a /plugins
parent8497b3daea44fe26fbc2d089a55e75a219e8d603 (diff)
Fix xv video and related page, fix possible crash when going back from related video
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MediaGeneric.hpp17
-rw-r--r--plugins/Page.hpp1
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