aboutsummaryrefslogtreecommitdiff
path: root/src/DownloadUtils.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-03-30 00:45:51 +0200
committerdec05eba <dec05eba@protonmail.com>2021-03-30 00:45:51 +0200
commit539d9b457c4f30ef0731a479772212e7ce8bfd7c (patch)
tree256aae0d3524918ba80d609cadd9063cd06fb453 /src/DownloadUtils.cpp
parent3ac540c21116cb9cc91cfd1d7b0dd6f6ded31123 (diff)
Remove tor option. Use torsocks instead (which is what quickmedia did anyways)
Diffstat (limited to 'src/DownloadUtils.cpp')
-rw-r--r--src/DownloadUtils.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp
index 33b2830..e1c628c 100644
--- a/src/DownloadUtils.cpp
+++ b/src/DownloadUtils.cpp
@@ -20,11 +20,9 @@ static const char *useragent_str = "user-agent: Mozilla/5.0 (X11; Linux x86_64)
namespace QuickMedia {
// TODO: Add timeout
- DownloadResult download_to_string(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args, bool use_tor, bool use_browser_useragent, bool fail_on_error) {
+ DownloadResult download_to_string(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args, bool use_browser_useragent, bool fail_on_error) {
sf::Clock timer;
std::vector<const char*> args;
- if(use_tor)
- args.push_back("torsocks");
args.insert(args.end(), { "curl", "-H", "Accept-Language: en-US,en;q=0.5", "-H", "Connection: keep-alive", "--compressed", "-s", "-L" });
if(fail_on_error)
args.push_back("-f");
@@ -52,7 +50,7 @@ namespace QuickMedia {
return DownloadResult::OK;
}
- DownloadResult download_to_string_cache(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args, bool use_tor, bool use_browser_useragent, DownloadErrorHandler error_handler, Path cache_path) {
+ DownloadResult download_to_string_cache(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args, bool use_browser_useragent, DownloadErrorHandler error_handler, Path cache_path) {
Path media_dir;
Path media_file_path;
if(cache_path.data.empty()) {
@@ -71,7 +69,7 @@ namespace QuickMedia {
return DownloadResult::ERR;
}
} else {
- DownloadResult download_result = download_to_string(url, result, additional_args, use_tor, use_browser_useragent, error_handler ? false : true);
+ DownloadResult download_result = download_to_string(url, result, additional_args, use_browser_useragent, error_handler ? false : true);
if(download_result == DownloadResult::OK && error_handler)
download_result = error_handler(result) ? DownloadResult::OK : DownloadResult::ERR;
if(download_result == DownloadResult::OK) {
@@ -90,7 +88,7 @@ namespace QuickMedia {
}
// TODO: Use this everywhere we want to save to file (such as manga download)
- DownloadResult download_to_file(const std::string &url, const std::string &destination_filepath, const std::vector<CommandArg> &additional_args, bool use_tor, bool use_browser_useragent) {
+ DownloadResult download_to_file(const std::string &url, const std::string &destination_filepath, const std::vector<CommandArg> &additional_args, bool use_browser_useragent) {
Path tmp_filepath = destination_filepath;
tmp_filepath.append(".tmp");
@@ -103,7 +101,7 @@ namespace QuickMedia {
args.push_back({ "-o", tmp_filepath.data.c_str() });
std::string dummy;
- DownloadResult res = download_to_string(url, dummy, std::move(args), use_tor, use_browser_useragent);
+ DownloadResult res = download_to_string(url, dummy, std::move(args), use_browser_useragent);
if(res != DownloadResult::OK) return res;
if(rename(tmp_filepath.data.c_str(), destination_filepath.c_str()) != 0) {
@@ -115,11 +113,9 @@ namespace QuickMedia {
}
// TODO: Add timeout
- DownloadResult download_to_json(const std::string &url, rapidjson::Document &result, const std::vector<CommandArg> &additional_args, bool use_tor, bool use_browser_useragent, bool fail_on_error) {
+ DownloadResult download_to_json(const std::string &url, rapidjson::Document &result, const std::vector<CommandArg> &additional_args, bool use_browser_useragent, bool fail_on_error) {
sf::Clock timer;
std::vector<const char*> args;
- if(use_tor)
- args.push_back("torsocks");
args.insert(args.end(), { "curl", "-H", "Accept-Language: en-US,en;q=0.5", "-H", "Connection: keep-alive", "--compressed", "-s", "-L" });
if(fail_on_error)
args.push_back("-f");