diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-05-31 18:03:57 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-05-31 18:05:01 +0200 |
commit | 34fef69fd468f695b3b5817da6a9980ac7b5860d (patch) | |
tree | 9b0f50279b269e6e1a429bd313d24491ff9cc4e7 /src/plugins | |
parent | 68a2660da9ea4c660feda5d8569a8f43108964ec (diff) |
Add dmenu option
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Dmenu.cpp | 23 | ||||
-rw-r--r-- | src/plugins/Pornhub.cpp | 13 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/plugins/Dmenu.cpp b/src/plugins/Dmenu.cpp new file mode 100644 index 0000000..a3b354b --- /dev/null +++ b/src/plugins/Dmenu.cpp @@ -0,0 +1,23 @@ +#include "../../plugins/Dmenu.hpp" +#include <iostream> + +namespace QuickMedia { + Dmenu::Dmenu() : Plugin("dmenu") { + std::string line; + while(std::getline(std::cin, line)) { + stdin_data.push_back(std::move(line)); + } + } + + PluginResult Dmenu::get_front_page(BodyItems &result_items) { + for(const std::string &line_data : stdin_data) { + result_items.push_back(std::make_unique<BodyItem>(line_data)); + } + return PluginResult::OK; + } + + SearchResult Dmenu::search(const std::string &text, BodyItems &result_items) { + std::cout << text << std::endl; + return SearchResult::OK; + } +}
\ No newline at end of file diff --git a/src/plugins/Pornhub.cpp b/src/plugins/Pornhub.cpp index c94532b..9a7242a 100644 --- a/src/plugins/Pornhub.cpp +++ b/src/plugins/Pornhub.cpp @@ -12,19 +12,6 @@ namespace QuickMedia { return strstr(str, substr); } - static void iterate_suggestion_result(const Json::Value &value, BodyItems &result_items, int &iterate_count) { - ++iterate_count; - if(value.isArray()) { - for(const Json::Value &child : value) { - iterate_suggestion_result(child, result_items, iterate_count); - } - } else if(value.isString() && iterate_count > 2) { - std::string title = value.asString(); - auto item = std::make_unique<BodyItem>(title); - result_items.push_back(std::move(item)); - } - } - // TODO: Speed this up by using string.find instead of parsing html SuggestionResult Pornhub::update_search_suggestions(const std::string &text, BodyItems &result_items) { std::string url = "https://www.pornhub.com/video/search?search="; |