diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-02-16 09:43:17 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-02-16 09:43:17 +0100 |
commit | 1786ba0b87d9883e4c75126e5d72af02134cc8b8 (patch) | |
tree | df3b021ef171417239bf770bfdee00ec40363f22 | |
parent | fix(crates/yt_dlp/error::PythonError): Add the python type as `kind` (diff) | |
download | yt-1786ba0b87d9883e4c75126e5d72af02134cc8b8.zip |
fix(crates/yt_dlp/progress_hook): Print the progress to stderr
-rw-r--r-- | crates/yt_dlp/src/lib.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs index 8bd2748..15d886c 100644 --- a/crates/yt_dlp/src/lib.rs +++ b/crates/yt_dlp/src/lib.rs @@ -12,7 +12,7 @@ #![allow(unsafe_op_in_unsafe_fn)] #![allow(clippy::missing_errors_doc)] -use std::io::stdout; +use std::io::stderr; use std::{env, process}; use std::{fs::File, io::Write}; @@ -113,10 +113,10 @@ pub fn progress_hook(py: Python<'_>, input: &Bound<'_, PyDict>) -> PyResult<()> // see: https://en.wikipedia.org/wiki/ANSI_escape_code#Control_Sequence_Introducer_commands const CSI: &str = "\x1b["; fn clear_whole_line() { - print!("{CSI}2K"); + eprint!("{CSI}2K"); } fn move_to_col(x: usize) { - print!("{CSI}{x}G"); + eprint!("{CSI}{x}G"); } // }}} @@ -251,7 +251,7 @@ pub fn progress_hook(py: Python<'_>, input: &Bound<'_, PyDict>) -> PyResult<()> clear_whole_line(); move_to_col(1); - print!( + eprint!( "'{}' [{}/{} at {}] -> [{} of {}{} {}] ", c!("34;1", get_title()), c!("33;1", Duration::from(Some(elapsed))), @@ -262,10 +262,10 @@ pub fn progress_hook(py: Python<'_>, input: &Bound<'_, PyDict>) -> PyResult<()> c!("31;1", format_bytes(total_bytes)), c!("36;1", format!("{:.02}%", percent)) ); - stdout().flush()?; + stderr().flush()?; } "finished" => { - println!("-> Finished downloading."); + eprintln!("-> Finished downloading."); } "error" => { // TODO: This should probably return an Err. But I'm not so sure where the error would |