From 65cf7681a04f2511db8c7829e9828b53a6676c88 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 2 Aug 2019 20:08:27 +0200 Subject: Convert to sfml, starting on manganelo and youtube --- src/Plugin.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/Plugin.cpp (limited to 'src/Plugin.cpp') diff --git a/src/Plugin.cpp b/src/Plugin.cpp new file mode 100644 index 0000000..d2fe925 --- /dev/null +++ b/src/Plugin.cpp @@ -0,0 +1,17 @@ +#include "../plugins/Plugin.hpp" +#include "../include/Program.h" + +static int accumulate_string(char *data, int size, void *userdata) { + std::string *str = (std::string*)userdata; + str->append(data, size); + return 0; +} + +namespace QuickMedia { + DownloadResult Plugin::download_to_string(const std::string &url, std::string &result) { + const char *args[] = { "curl", "-H", "Accept-Language: en-US,en;q=0.5", "--compressed", "-s", "-L", url.c_str(), nullptr }; + if(exec_program(args, accumulate_string, &result) != 0) + return DownloadResult::NET_ERR; + return DownloadResult::OK; + } +} \ No newline at end of file -- cgit v1.2.3