From 089ed86dae1ef5519c327142f69a0b86fc2b6043 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 7 Oct 2024 19:32:00 +0200 Subject: feat(crates/yt_dlp): Make saving the downloaded info.json configurable This avoids having to recompile the application to save the downloaded info.json, and simply requires setting an environment variable. --- crates/yt_dlp/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs index 2f554a9..f958895 100644 --- a/crates/yt_dlp/src/lib.rs +++ b/crates/yt_dlp/src/lib.rs @@ -8,7 +8,8 @@ // You should have received a copy of the License along with this program. // If not, see . -// use std::{fs::File, io::Write}; +use std::env; +use std::{fs::File, io::Write}; use std::{path::PathBuf, sync::Once}; @@ -308,8 +309,12 @@ pub async fn extract_info( let result_str = json_dumps(py, result)?; - //let mut file = File::create("output.info.json").unwrap(); - //write!(file, "{}", result_str).unwrap(); + if let Ok(confirm) = env::var("YT_STORE_INFO_JSON") { + if confirm == "yes" { + let mut file = File::create("output.info.json").unwrap(); + write!(file, "{}", result_str).unwrap(); + } + } Ok(serde_json::from_str(&result_str) .expect("Python should be able to produce correct json")) -- cgit 1.4.1