From dd135af27160f954c8f9c937d1fdb5b2a1032ccf Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Tue, 26 May 2026 18:11:35 +0200 Subject: feat(yt/download/hooks): Show progress of post-processors Otherwise, `yt` will just show everything downloaded, but does not continue. Now users see, what is _actually_ happening. --- crates/yt_dlp/src/info_json.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'crates/yt_dlp/src/info_json.rs') diff --git a/crates/yt_dlp/src/info_json.rs b/crates/yt_dlp/src/info_json.rs index 402acb4..df49218 100644 --- a/crates/yt_dlp/src/info_json.rs +++ b/crates/yt_dlp/src/info_json.rs @@ -54,3 +54,39 @@ pub fn json_dumps(input: &Bound<'_, PyDict>) -> serde_json::Map unreachable!("These should not be json.dumps output"), } } + +/// # Panics +/// If expectation about python operations fail. +#[must_use] +pub fn filter_dict(input: Bound<'_, PyDict>) -> Bound<'_, PyDict> { + let new_dict = PyDict::new(input.py()); + + input + .into_iter() + .filter_map(|(name, value)| { + let real_name = name.extract::().expect("Should always be a string"); + + if real_name.starts_with('_') { + None + } else { + let value = if value.is_instance_of::() { + filter_dict( + value + .cast_into::() + .expect("to be a dict, because we checked"), + ) + .into_any() + } else { + value + }; + Some((real_name, value)) + } + }) + .for_each(|(key, value)| { + new_dict + .set_item(&key, value) + .expect("This is a transposition, should always be valid"); + }); + + new_dict +} -- cgit v1.3.1