aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-02-14 16:07:11 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-02-14 16:07:11 +0100
commit325b23039850953705a57c0a331045b169548751 (patch)
tree79aea36ddc9eac33dea109335b7bec714f3e87ff
parentfix(crates/libmpv2): Improve the error message for the `RawError` (diff)
downloadyt-325b23039850953705a57c0a331045b169548751.zip
fix(crates/yt_dlp): Avoid printing the file extension in the progress display
The file extension should not be relevant for a user.
-rw-r--r--crates/yt_dlp/src/lib.rs18
1 files changed, 5 insertions, 13 deletions
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, "<No Subtitle Language>", "info_dict", "name"}
)
}
- title_extension @ ("webm" | "mp4" | "m4a") => {
- if add_extension {
- format!(
- "{} ({})",
- default_get! { as_str, "<No title>", "info_dict", "title"},
- title_extension
- )
- } else {
- default_get! { as_str, "<No title>", "info_dict", "title"}.to_owned()
- }
+ "webm" | "mp4" | "mp3" | "m4a" => {
+ default_get! { as_str, "<No title>", "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!"),
};