diff --git a/src/rust/ffmpeg.rs b/src/rust/ffmpeg.rs index ede3eda..bf46e77 100644 --- a/src/rust/ffmpeg.rs +++ b/src/rust/ffmpeg.rs @@ -4,11 +4,11 @@ use std::io::{self, Write}; use std::path::{Path, PathBuf}; use std::process::Command; use std::str; +use tracing::debug; pub fn bg_from_video(video: &Path) -> PathBuf { let video = PathBuf::from(video); - println!("{:?}", video); - println!("{:?}", video.file_name()); + debug!(?video); let mut data_dir = dirs::data_local_dir().unwrap(); data_dir.push("lumina"); data_dir.push("thumbnails"); @@ -29,11 +29,11 @@ pub fn bg_from_video(video: &Path) -> PathBuf { let mut log = str::from_utf8(&output_duration.stderr) .expect("Using non UTF-8 characters") .to_string(); - println!("{log}"); + debug!(log); if let Some(duration_index) = log.find("Duration") { let mut duration = log.split_off(duration_index + 10); duration.truncate(11); - println!("rust-duration-is: {duration}"); + // debug!("rust-duration-is: {duration}"); let mut hours = String::from(""); let mut minutes = String::from(""); let mut seconds = String::from(""); @@ -54,10 +54,7 @@ pub fn bg_from_video(video: &Path) -> PathBuf { minutes += hours * 60; seconds += minutes * 60; at_second = seconds / 5; - println!( - "hours: {}, minutes: {}, seconds: {}, at_second: {}", - hours, minutes, seconds, at_second - ); + debug!(hours, minutes, seconds, at_second); } let _output = Command::new("ffmpeg") .args(&[ @@ -75,7 +72,7 @@ pub fn bg_from_video(video: &Path) -> PathBuf { // io::stdout().write_all(&output.stdout).unwrap(); // io::stderr().write_all(&output.stderr).unwrap(); } else { - println!("Screenshot already exists"); + debug!("Screenshot already exists"); } screenshot } diff --git a/src/rust/ytdl.rs b/src/rust/ytdl.rs index 6bbc92f..14a5b1c 100644 --- a/src/rust/ytdl.rs +++ b/src/rust/ytdl.rs @@ -27,7 +27,8 @@ mod ytdl { use cxx_qt::{CxxQtType, Threading}; use cxx_qt_lib::{QString, QUrl}; use dirs; -use std::{fs, thread, pin::Pin}; +use tracing::debug; +use std::{fs, pin::Pin}; use youtube_dl::YoutubeDl; #[derive(Clone, Default)] @@ -47,7 +48,6 @@ impl ytdl::Ytdl { if !url.is_valid() { false } else { - let data_dir = dirs::data_local_dir().unwrap(); if let Some(mut data_dir) = dirs::data_local_dir() { data_dir.push("lumina"); data_dir.push("ytdl"); @@ -55,7 +55,7 @@ impl ytdl::Ytdl { fs::create_dir(&data_dir) .expect("Could not create ytdl dir"); } - println!("{:?}", data_dir); + debug!(?data_dir); self.as_mut().set_loading(true); let thread = self.qt_thread(); let runtime = @@ -63,7 +63,7 @@ impl ytdl::Ytdl { runtime.spawn(async move { let url = url.to_string(); let output_dirs = data_dir.to_str().unwrap(); - println!("{output_dirs}"); + debug!(output_dirs); let ytdl = YoutubeDl::new(url) .socket_timeout("15") .output_directory(output_dirs) @@ -73,9 +73,7 @@ impl ytdl::Ytdl { .unwrap(); let output = ytdl.into_single_video().unwrap(); - println!("{:?}", output.title); - println!("{:?}", output.thumbnail); - println!("{:?}", output.url); + debug!(output.title, output.thumbnail, output.url); let title = QString::from(&output.title); let thumbnail = QUrl::from( &output.thumbnail.unwrap_or_default(), @@ -87,7 +85,7 @@ impl ytdl::Ytdl { file.push_str( &output.ext.unwrap_or_default(), ); - println!("{:?}", file); + debug!(file); thread.queue(move |mut qobject_ytdl| { qobject_ytdl.as_mut().set_loaded(true);