aboutsummaryrefslogtreecommitdiff
path: root/src/DownloadUtils.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-17 09:47:45 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-17 09:59:29 +0100
commit453eac7f1f5ef70390ec51087fc1f190811a7507 (patch)
tree21a32ef6de9a3d7c29562484104b56c12518a6f0 /src/DownloadUtils.cpp
parentfc49d40c0d2f6edbbe9dde1f1b53d6a17e9d9f7d (diff)
Replace sfml with mgl
Diffstat (limited to 'src/DownloadUtils.cpp')
-rw-r--r--src/DownloadUtils.cpp20
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;
}
}