Skip to content

Commit

Permalink
download function change.
Browse files Browse the repository at this point in the history
  • Loading branch information
xnti committed Mar 30, 2022
1 parent 81222af commit de89231
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
15 changes: 3 additions & 12 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ void xnti::app::run(const char *url)

std::cout << "Starting to download video..."
<< "\n";
pA->download_video(video_url, video_output);
pA->download(video_url, video_output);
std::cout << "Video downloaded successfully..."
<< "\n";
std::cout << "Starting to download audio..."
<< "\n";
pA->download_audio(audio_url, audio_output);
pA->download(audio_url, audio_output);
std::cout << "Audio downloaded successfully..."
<< "\n";
std::cout << "Merging them into one file..."
Expand All @@ -52,7 +52,7 @@ void xnti::app::run(const char *url)
<< "\n";
}

bool xnti::app::download_video(std::string video_url, std::string output_name)
bool xnti::app::download(std::string video_url, std::string output_name)
{
auto ofstream = std::ofstream(output_name.c_str());
auto session = cpr::Session();
Expand All @@ -61,15 +61,6 @@ bool xnti::app::download_video(std::string video_url, std::string output_name)
return true;
}

bool xnti::app::download_audio(std::string audio_url, std::string output_name)
{
auto ofstream = std::ofstream(output_name.c_str());
auto session = cpr::Session();
session.SetUrl(cpr::Url{audio_url});
auto response = session.Download(ofstream);
return true;
}

bool xnti::app::merge_video_audio(std::string video_path, std::string audio_path, std::string output)
{
std::string command = "ffmpeg -y -i " + video_path + " -i " + audio_path + " -c:v copy -c:a aac " + output;
Expand Down
3 changes: 1 addition & 2 deletions src/include/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ namespace xnti {
public:
void run(const char* url);
std::string get_video_audio_url(const char* video_url, const char* res);
bool download_video(std::string video_url, std::string output_name);
bool download_audio(std::string audio_url, std::string output_name);
bool download(std::string video_url, std::string output_name);
bool merge_video_audio(std::string video_path, std::string audio_path, std::string output);
bool clerance(std::string video_path, std::string audio_path, std::string output_path);
};
Expand Down

0 comments on commit de89231

Please # to comment.