diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Plugin.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/plugins/Plugin.cpp b/src/plugins/Plugin.cpp index c56ff67..d1490d5 100644 --- a/src/plugins/Plugin.cpp +++ b/src/plugins/Plugin.cpp @@ -28,22 +28,6 @@ namespace QuickMedia { return {}; } - DownloadResult download_to_string(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args) { - sf::Clock timer; - std::vector<const char*> args = { "curl", "-f", "-H", "Accept-Language: en-US,en;q=0.5", "--compressed", "-s", "-L" }; - for(const CommandArg &arg : additional_args) { - args.push_back(arg.option.c_str()); - args.push_back(arg.value.c_str()); - } - args.push_back("--"); - args.push_back(url.c_str()); - args.push_back(nullptr); - if(exec_program(args.data(), accumulate_string, &result) != 0) - return DownloadResult::NET_ERR; - fprintf(stderr, "Download duration for %s: %d ms\n", url.c_str(), timer.getElapsedTime().asMilliseconds()); - return DownloadResult::OK; - } - static bool is_whitespace(char c) { return c == ' ' || c == '\n' || c == '\t' || c == '\v'; } @@ -112,4 +96,23 @@ namespace QuickMedia { return result.str(); } + + DownloadResult Plugin::download_to_string(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args) { + sf::Clock timer; + std::vector<const char*> args; + if(use_tor) + args.push_back("torsocks"); + args.insert(args.end(), { "curl", "-f", "-H", "Accept-Language: en-US,en;q=0.5", "--compressed", "-s", "-L" }); + for(const CommandArg &arg : additional_args) { + args.push_back(arg.option.c_str()); + args.push_back(arg.value.c_str()); + } + args.push_back("--"); + args.push_back(url.c_str()); + args.push_back(nullptr); + if(exec_program(args.data(), accumulate_string, &result) != 0) + return DownloadResult::NET_ERR; + fprintf(stderr, "Download duration for %s: %d ms\n", url.c_str(), timer.getElapsedTime().asMilliseconds()); + return DownloadResult::OK; + } }
\ No newline at end of file |