diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-05-26 18:11:35 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-05-26 18:14:48 +0200 |
| commit | dd135af27160f954c8f9c937d1fdb5b2a1032ccf (patch) | |
| tree | 36814abb76a4c5c17ccd3eb7ff9c6df291ad08c0 /crates/yt_dlp/src/info_json.rs | |
| parent | build(update.sh): Remove all redundant `update.sh` files (diff) | |
| download | yt-dd135af27160f954c8f9c937d1fdb5b2a1032ccf.zip | |
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.
Diffstat (limited to 'crates/yt_dlp/src/info_json.rs')
| -rw-r--r-- | crates/yt_dlp/src/info_json.rs | 36 |
1 files changed, 36 insertions, 0 deletions
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<String, serde_js _ => 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::<String>().expect("Should always be a string"); + + if real_name.starts_with('_') { + None + } else { + let value = if value.is_instance_of::<PyDict>() { + filter_dict( + value + .cast_into::<PyDict>() + .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 +} |
