diff options
Diffstat (limited to 'include/Downloader.hpp')
-rw-r--r-- | include/Downloader.hpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/include/Downloader.hpp b/include/Downloader.hpp index cc15e5d..cb70f2e 100644 --- a/include/Downloader.hpp +++ b/include/Downloader.hpp @@ -1,6 +1,5 @@ #pragma once -#include "../plugins/youtube/YoutubeMediaProxy.hpp" #include "Path.hpp" #include "AsyncTask.hpp" #include <string> @@ -46,7 +45,7 @@ namespace QuickMedia { AsyncTask<bool> header_reader; std::string header; int64_t content_length = -1; - size_t downloaded_since_last_check = 0; + int64_t downloaded_since_last_check = 0; float progress = 0.0f; std::mutex content_length_mutex; std::string progress_text; @@ -80,9 +79,26 @@ namespace QuickMedia { int64_t content_length; }; + struct YoutubeReadProgram { + ReadProgram read_program; + int64_t offset = 0; + int64_t content_length = -1; + int64_t bytes_downloaded = 0; + int64_t downloaded_since_last_check = 0; + char *url = nullptr; + std::string output_filepath; + std::string output_filepath_tmp; + double progress = 0.0; + std::string progress_text; + std::string download_speed_text; + bool finished = false; + }; + class YoutubeDownloader : public Downloader { public: YoutubeDownloader(const MediaMetadata &video_metadata, const MediaMetadata &audio_metadata, const std::string &output_filepath); + ~YoutubeDownloader(); + bool start() override; bool stop(bool download_completed) override; DownloadUpdateStatus update() override; @@ -90,15 +106,14 @@ namespace QuickMedia { std::string get_progress_text() override; std::string get_download_speed_text() override; private: - CurlDownloader* get_min_progress_downloader(); + YoutubeReadProgram* get_min_progress_downloader(); + DownloadUpdateStatus update(size_t program_index); private: MediaMetadata video_metadata; MediaMetadata audio_metadata; std::string video_output_filepath; std::string audio_output_filepath; - std::unique_ptr<CurlDownloader> downloaders[2]; - AsyncTask<void> downloader_task; - std::unique_ptr<YoutubeMediaProxy> youtube_video_media_proxy; - std::unique_ptr<YoutubeMediaProxy> youtube_audio_media_proxy; + YoutubeReadProgram *program[2]; + AsyncTask<bool> downloader_tasks[2]; }; }
\ No newline at end of file |