From 325b23039850953705a57c0a331045b169548751 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Fri, 14 Feb 2025 16:07:11 +0100 Subject: fix(crates/yt_dlp): Avoid printing the file extension in the progress display The file extension should not be relevant for a user. --- crates/yt_dlp/src/lib.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'crates') diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs index 970bfe2..88ef996 100644 --- a/crates/yt_dlp/src/lib.rs +++ b/crates/yt_dlp/src/lib.rs @@ -198,7 +198,7 @@ pub fn progress_hook(py: Python<'_>, input: &Bound<'_, PyDict>) -> PyResult<()> format!("{bytes}/s") } - let get_title = |add_extension: bool| -> String { + let get_title = || -> String { match get! {is_string, as_str, "info_dict", "ext"} { "vtt" => { format!( @@ -206,16 +206,8 @@ pub fn progress_hook(py: Python<'_>, input: &Bound<'_, PyDict>) -> PyResult<()> default_get! {as_str, "", "info_dict", "name"} ) } - title_extension @ ("webm" | "mp4" | "m4a") => { - if add_extension { - format!( - "{} ({})", - default_get! { as_str, "", "info_dict", "title"}, - title_extension - ) - } else { - default_get! { as_str, "", "info_dict", "title"}.to_owned() - } + "webm" | "mp4" | "mp3" | "m4a" => { + default_get! { as_str, "", "info_dict", "title"}.to_owned() } other => panic!("The extension '{other}' is not yet implemented"), } @@ -259,7 +251,7 @@ pub fn progress_hook(py: Python<'_>, input: &Bound<'_, PyDict>) -> PyResult<()> print!( "'{}' [{}/{} at {}] -> [{} of {}{} {}] ", - c!("34;1", get_title(true)), + c!("34;1", get_title()), c!("33;1", Duration::from(Some(elapsed))), c!("33;1", Duration::from(Some(eta))), c!("32;1", format_speed(speed)), @@ -274,7 +266,7 @@ pub fn progress_hook(py: Python<'_>, input: &Bound<'_, PyDict>) -> PyResult<()> println!("-> Finished downloading."); } "error" => { - panic!("-> Error while downloading: {}", get_title(true)) + panic!("-> Error while downloading: {}", get_title()) } other => unreachable!("'{other}' should not be a valid state!"), }; -- cgit 1.4.1