From ca875b39ac35ac1499c303672f7217e2a7bbcab1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 19 Jun 2021 14:10:44 +0200 Subject: Fix youtube audio download downloading video when not needed --- src/QuickMedia.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/QuickMedia.cpp') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index c02b9ab..9613199 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -6453,8 +6453,15 @@ namespace QuickMedia { bool start() override { remove(output_filepath.c_str()); - std::vector args = { "youtube-dl", "-f", "bestvideo+bestaudio/best", "--no-warnings", "--no-continue", "--output", output_filepath.c_str(), "--newline" }; - if(no_video) args.push_back("-x"); + std::vector args = { "youtube-dl", "--no-warnings", "--no-continue", "--output", output_filepath.c_str(), "--newline" }; + if(no_video) { + args.push_back("-f"); + args.push_back("bestaudio/best"); + args.push_back("-x"); + } else { + args.push_back("-f"); + args.push_back("bestvideo+bestaudio/best"); + } args.insert(args.end(), { "--", url.c_str(), nullptr }); if(exec_program_pipe(args.data(), &read_program) != 0) @@ -6580,8 +6587,15 @@ namespace QuickMedia { if(download_use_youtube_dl) { task_result = run_task_with_loading_screen([this, url, &filename]{ std::string json_str; - std::vector args = { "youtube-dl", "-f", "bestvideo+bestaudio/best", "--skip-download", "--print-json", "--no-warnings" }; - if(no_video) args.push_back("-x"); + std::vector args = { "youtube-dl", "--skip-download", "--print-json", "--no-warnings" }; + if(no_video) { + args.push_back("-f"); + args.push_back("bestaudio/best"); + args.push_back("-x"); + } else { + args.push_back("-f"); + args.push_back("bestvideo+bestaudio/best"); + } args.insert(args.end(), { "--", url, nullptr }); if(exec_program(args.data(), accumulate_string, &json_str) != 0) return false; -- cgit v1.2.3