diff options
Diffstat (limited to 'src/plugins/Pornhub.cpp')
-rw-r--r-- | src/plugins/Pornhub.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/plugins/Pornhub.cpp b/src/plugins/Pornhub.cpp index 77d5594..afdd8fc 100644 --- a/src/plugins/Pornhub.cpp +++ b/src/plugins/Pornhub.cpp @@ -1,4 +1,5 @@ #include "../../plugins/Pornhub.hpp" +#include "../../include/StringUtils.hpp" #include <quickmedia/HtmlSearch.h> #include <string.h> @@ -11,14 +12,13 @@ namespace QuickMedia { return strstr(str, substr); } - // TODO: Speed this up by using string.find instead of parsing html - SuggestionResult Pornhub::update_search_suggestions(const std::string &text, BodyItems &result_items) { + SearchResult PornhubSearchPage::search(const std::string &str, BodyItems &result_items) { std::string url = "https://www.pornhub.com/video/search?search="; - url += url_param_encode(text); + url += url_param_encode(str); std::string website_data; - if(download_to_string(url, website_data, {}, use_tor) != DownloadResult::OK) - return SuggestionResult::NET_ERR; + if(download_to_string(url, website_data, {}, is_tor_enabled()) != DownloadResult::OK) + return SearchResult::NET_ERR; struct ItemData { BodyItems *result_items; @@ -65,14 +65,21 @@ namespace QuickMedia { cleanup: quickmedia_html_search_deinit(&html_search); - return result == 0 ? SuggestionResult::OK : SuggestionResult::ERR; + return result == 0 ? SearchResult::OK : SearchResult::ERR; } - BodyItems Pornhub::get_related_media(const std::string &url) { + PluginResult PornhubSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) { + (void)title; + (void)url; + result_tabs.push_back(Tab{create_body(), std::make_unique<PornhubVideoPage>(program), nullptr}); + return PluginResult::OK; + } + + BodyItems PornhubVideoPage::get_related_media(const std::string &url) { BodyItems result_items; std::string website_data; - if(download_to_string(url, website_data, {}, use_tor) != DownloadResult::OK) + if(download_to_string(url, website_data, {}, is_tor_enabled()) != DownloadResult::OK) return result_items; struct ItemData { |