diff options
Diffstat (limited to 'src/DownloadUtils.cpp')
-rw-r--r-- | src/DownloadUtils.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp index 6df9c74..584d4a3 100644 --- a/src/DownloadUtils.cpp +++ b/src/DownloadUtils.cpp @@ -5,8 +5,8 @@ #include "../external/hash-library/sha256.h" #include <unistd.h> #include <limits.h> -#include <SFML/System/Clock.hpp> -#include <SFML/Window/Event.hpp> +#include <mglpp/system/Clock.hpp> +#include <mglpp/window/Event.hpp> #include <rapidjson/document.h> #include <rapidjson/filereadstream.h> @@ -86,7 +86,7 @@ namespace QuickMedia { DownloadResult download_head_to_string(const std::string &url, std::string &result, bool use_browser_useragent, bool fail_on_error) { result.clear(); - sf::Clock timer; + mgl::Clock timer; std::vector<const char*> args; args.insert(args.end(), { "curl", "-I", "-g", "-H", "Accept-Language: en-US,en;q=0.5", "-H", "Connection: keep-alive", "--compressed", "-s" }); if(fail_on_error) @@ -107,13 +107,13 @@ namespace QuickMedia { } 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()); + fprintf(stderr, "Download duration for %s: %d ms\n", url.c_str(), (int)(timer.get_elapsed_time_seconds() * 1000.0)); return DownloadResult::OK; } DownloadResult url_get_remote_name(const std::string &url, std::string &result, bool use_browser_useragent) { result.clear(); - sf::Clock timer; + mgl::Clock timer; std::vector<const char*> args; args.insert(args.end(), { "curl", "-I", "-g", "-H", "Accept-Language: en-US,en;q=0.5", "-H", "Connection: keep-alive", "--compressed", "-s" }); if(use_browser_useragent) { @@ -133,7 +133,7 @@ namespace QuickMedia { std::string header; if(exec_program(args.data(), accumulate_string, &header) != 0) return DownloadResult::NET_ERR; - fprintf(stderr, "Download duration for %s: %d ms\n", url.c_str(), timer.getElapsedTime().asMilliseconds()); + fprintf(stderr, "Download duration for %s: %d ms\n", url.c_str(), (int)(timer.get_elapsed_time_seconds() * 1000.0)); std::string content_disposition = header_extract_value(header, "content-disposition"); // TODO: after filename*= the encoding type will follow. We need to support other formats than utf-8 as well @@ -195,7 +195,7 @@ namespace QuickMedia { // TODO: Add timeout 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, bool cloudflare_bypass, std::vector<std::string> *headers, int download_limit) { result.clear(); - sf::Clock timer; + mgl::Clock timer; std::vector<const char*> args; args.insert(args.end(), { "curl", "-H", "Accept-Language: en-US,en;q=0.5", "-H", "Connection: keep-alive", "--compressed", "-g", "-s", "-L" }); if(fail_on_error) @@ -234,7 +234,7 @@ namespace QuickMedia { if(exec_program(args.data(), accumulate_string_with_header, &download_userdata) != 0) return DownloadResult::NET_ERR; - fprintf(stderr, "Download duration for %s: %d ms\n", url.c_str(), timer.getElapsedTime().asMilliseconds()); + fprintf(stderr, "Download duration for %s: %d ms\n", url.c_str(), (int)(timer.get_elapsed_time_seconds() * 1000.0)); return DownloadResult::OK; } @@ -307,7 +307,7 @@ namespace QuickMedia { // TODO: Add timeout 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; + mgl::Clock timer; std::vector<const char*> args; args.insert(args.end(), { "curl", "-H", "Accept-Language: en-US,en;q=0.5", "-H", "Connection: keep-alive", "--compressed", "-g", "-s", "-L" }); if(fail_on_error) @@ -350,7 +350,7 @@ namespace QuickMedia { fclose(file); wait_program(read_program.pid); - fprintf(stderr, "Download duration for %s: %d ms\n", url.c_str(), timer.getElapsedTime().asMilliseconds()); + fprintf(stderr, "Download duration for %s: %d ms\n", url.c_str(), (int)(timer.get_elapsed_time_seconds() * 1000.0)); return parse_result.IsError() ? DownloadResult::ERR : DownloadResult::OK; } } |