about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-25 15:44:49 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-25 15:44:49 +0200
commit5e46f4726f308cbe25a84e71e083ffe99e9e4c2d (patch)
tree210253b462323d934e09abfcb07d3386629b9e50
parentbuild(update.sh): Correct path specifications and upgrade incompatible deps (diff)
downloadyt-5e46f4726f308cbe25a84e71e083ffe99e9e4c2d.tar.gz
yt-5e46f4726f308cbe25a84e71e083ffe99e9e4c2d.zip
fix(yt_dlp/lib/hook): Don't print download progress, when debug is logged
This makes interpreting the debug output easier.
-rw-r--r--crates/yt_dlp/src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs
index 37d0945..d9b10c2 100644
--- a/crates/yt_dlp/src/lib.rs
+++ b/crates/yt_dlp/src/lib.rs
@@ -15,7 +15,7 @@ use std::{path::PathBuf, sync::Once};
 use crate::{duration::Duration, logging::setup_logging, wrapper::info_json::InfoJson};
 
 use bytes::Bytes;
-use log::{info, warn};
+use log::{info, log_enabled, warn, Level};
 use pyo3::types::{PyString, PyTuple, PyTupleMethods};
 use pyo3::{
     pyfunction,
@@ -82,6 +82,12 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)
 
 #[pyfunction]
 pub fn progress_hook<'a>(py: Python, input: Bound<'_, PyDict>) -> PyResult<()> {
+    // Only add the handler, if the log-level is higher than Debug (this avoids covering debug
+    // messages).
+    if log_enabled!(Level::Debug) {
+        return Ok(());
+    }
+
     let input: serde_json::Map<String, Value> = serde_json::from_str(&json_dumps(
         py,
         input