From 453eac7f1f5ef70390ec51087fc1f190811a7507 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 17 Nov 2021 09:47:45 +0100 Subject: Replace sfml with mgl --- src/DownloadUtils.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/DownloadUtils.cpp') 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 #include -#include -#include +#include +#include #include #include @@ -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 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 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 &additional_args, bool use_browser_useragent, bool fail_on_error, bool cloudflare_bypass, std::vector *headers, int download_limit) { result.clear(); - sf::Clock timer; + mgl::Clock timer; std::vector 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 &additional_args, bool use_browser_useragent, bool fail_on_error) { - sf::Clock timer; + mgl::Clock timer; std::vector 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; } } -- cgit v1.2.3