aboutsummaryrefslogtreecommitdiff
path: root/src/Plugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Plugin.cpp')
-rw-r--r--src/Plugin.cpp17
1 files changed, 17 insertions, 0 deletions
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