From 3c9ca2c97ae7a2b39bfe5c5e8a9d7941f9fb1525 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 8 Aug 2019 04:13:03 +0200 Subject: Youtube: use real search for search suggestions (better results, thumbnails, directly to result) --- plugins/Manganelo.hpp | 6 ++++-- plugins/Plugin.hpp | 5 ++++- plugins/Youtube.hpp | 8 +++++--- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/Manganelo.hpp b/plugins/Manganelo.hpp index 01311e1..5720199 100644 --- a/plugins/Manganelo.hpp +++ b/plugins/Manganelo.hpp @@ -5,12 +5,14 @@ namespace QuickMedia { class Manganelo : public Plugin { public: - SearchResult search(const std::string &url, std::vector> &result_items, Page &next_page) override; + SearchResult search(const std::string &url, std::vector> &result_items) override; SuggestionResult update_search_suggestions(const std::string &text, std::vector> &result_items) override; ImageResult get_image_by_index(const std::string &url, int index, std::string &image_data); ImageResult get_number_of_images(const std::string &url, int &num_images); bool search_suggestions_has_thumbnails() const override { return true; } - bool search_results_has_thumbnails() const override { return true; } + bool search_results_has_thumbnails() const override { return false; } + int get_search_delay() const override { return 150; } + Page get_page_after_search() const override { return Page::EPISODE_LIST; } private: // Caches url. If the same url is requested multiple times then the cache is used ImageResult get_image_urls_for_chapter(const std::string &url); diff --git a/plugins/Plugin.hpp b/plugins/Plugin.hpp index 3df53ca..54d49e5 100644 --- a/plugins/Plugin.hpp +++ b/plugins/Plugin.hpp @@ -44,11 +44,14 @@ namespace QuickMedia { public: virtual ~Plugin() = default; - virtual SearchResult search(const std::string &text, std::vector> &result_items, Page &next_page) = 0; + virtual SearchResult search(const std::string &text, std::vector> &result_items); virtual SuggestionResult update_search_suggestions(const std::string &text, std::vector> &result_items); virtual std::vector> get_related_media(const std::string &url); virtual bool search_suggestions_has_thumbnails() const = 0; virtual bool search_results_has_thumbnails() const = 0; + virtual int get_search_delay() const = 0; + virtual bool search_suggestion_is_search() const { return false; } + virtual Page get_page_after_search() const = 0; protected: std::string url_param_encode(const std::string ¶m) const; }; diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index e8cc2c2..64a0d6b 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -5,10 +5,12 @@ namespace QuickMedia { class Youtube : public Plugin { public: - SearchResult search(const std::string &text, std::vector> &result_items, Page &next_page) override; SuggestionResult update_search_suggestions(const std::string &text, std::vector> &result_items) override; std::vector> get_related_media(const std::string &url) override; - bool search_suggestions_has_thumbnails() const override { return false; } - bool search_results_has_thumbnails() const override { return true; } + bool search_suggestions_has_thumbnails() const override { return true; } + bool search_results_has_thumbnails() const override { return false; } + int get_search_delay() const override { return 250; } + bool search_suggestion_is_search() const override { return true; } + Page get_page_after_search() const override { return Page::VIDEO_CONTENT; } }; } \ No newline at end of file -- cgit v1.2.3