about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-10-07 19:32:00 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-10-07 19:32:00 +0200
commit089ed86dae1ef5519c327142f69a0b86fc2b6043 (patch)
tree242c34659d4f2c16eb19b30364c25eaf15ac51de
parentbuild(crates/libmpv2/update.sh): Correctly specify child update paths (diff)
downloadyt-089ed86dae1ef5519c327142f69a0b86fc2b6043.tar.gz
yt-089ed86dae1ef5519c327142f69a0b86fc2b6043.zip
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.
Diffstat (limited to '')
-rw-r--r--crates/yt_dlp/src/lib.rs11
1 files 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 <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
-// 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"))