diff options
Diffstat (limited to 'src/plugins/Manganelo.cpp')
-rw-r--r-- | src/plugins/Manganelo.cpp | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp index 5be64ca..52b9ebd 100644 --- a/src/plugins/Manganelo.cpp +++ b/src/plugins/Manganelo.cpp @@ -1,7 +1,6 @@ #include "../../plugins/Manganelo.hpp" #include "../../include/Notification.hpp" #include <quickmedia/HtmlSearch.h> -#include <json/reader.h> namespace QuickMedia { struct BodyItemImageContext { @@ -77,21 +76,9 @@ namespace QuickMedia { search_term += url_param_encode(text); CommandArg data_arg = { "--data", std::move(search_term) }; - std::string server_response; - if(download_to_string(url, server_response, {data_arg}, use_tor) != DownloadResult::OK) - return SuggestionResult::NET_ERR; - - if(server_response.empty()) - return SuggestionResult::OK; - Json::Value json_root; - Json::CharReaderBuilder json_builder; - std::unique_ptr<Json::CharReader> json_reader(json_builder.newCharReader()); - std::string json_errors; - if(!json_reader->parse(&server_response[0], &server_response[server_response.size()], &json_root, &json_errors)) { - fprintf(stderr, "Manganelo suggestions json error: %s\n", json_errors.c_str()); - return SuggestionResult::ERR; - } + DownloadResult result = download_json(json_root, url, {data_arg}, true); + if(result != DownloadResult::OK) return download_result_to_suggestion_result(result); if(json_root.isArray()) { for(const Json::Value &child : json_root) { |