From 539d9b457c4f30ef0731a479772212e7ce8bfd7c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 30 Mar 2021 00:45:51 +0200 Subject: Remove tor option. Use torsocks instead (which is what quickmedia did anyways) --- src/DownloadUtils.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/DownloadUtils.cpp') 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 &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 &additional_args, bool use_browser_useragent, bool fail_on_error) { sf::Clock timer; std::vector 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 &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 &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 &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 &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 &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 &additional_args, bool use_browser_useragent, bool fail_on_error) { sf::Clock timer; std::vector 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"); -- cgit v1.2.3