using debug! more

This commit is contained in:
Chris Cochrun 2024-01-22 14:18:05 -06:00
parent c6c45b451e
commit b85d848d56
2 changed files with 12 additions and 17 deletions

View file

@ -4,11 +4,11 @@ use std::io::{self, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::Command; use std::process::Command;
use std::str; use std::str;
use tracing::debug;
pub fn bg_from_video(video: &Path) -> PathBuf { pub fn bg_from_video(video: &Path) -> PathBuf {
let video = PathBuf::from(video); let video = PathBuf::from(video);
println!("{:?}", video); debug!(?video);
println!("{:?}", video.file_name());
let mut data_dir = dirs::data_local_dir().unwrap(); let mut data_dir = dirs::data_local_dir().unwrap();
data_dir.push("lumina"); data_dir.push("lumina");
data_dir.push("thumbnails"); 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) let mut log = str::from_utf8(&output_duration.stderr)
.expect("Using non UTF-8 characters") .expect("Using non UTF-8 characters")
.to_string(); .to_string();
println!("{log}"); debug!(log);
if let Some(duration_index) = log.find("Duration") { if let Some(duration_index) = log.find("Duration") {
let mut duration = log.split_off(duration_index + 10); let mut duration = log.split_off(duration_index + 10);
duration.truncate(11); duration.truncate(11);
println!("rust-duration-is: {duration}"); // debug!("rust-duration-is: {duration}");
let mut hours = String::from(""); let mut hours = String::from("");
let mut minutes = String::from(""); let mut minutes = String::from("");
let mut seconds = String::from(""); let mut seconds = String::from("");
@ -54,10 +54,7 @@ pub fn bg_from_video(video: &Path) -> PathBuf {
minutes += hours * 60; minutes += hours * 60;
seconds += minutes * 60; seconds += minutes * 60;
at_second = seconds / 5; at_second = seconds / 5;
println!( debug!(hours, minutes, seconds, at_second);
"hours: {}, minutes: {}, seconds: {}, at_second: {}",
hours, minutes, seconds, at_second
);
} }
let _output = Command::new("ffmpeg") let _output = Command::new("ffmpeg")
.args(&[ .args(&[
@ -75,7 +72,7 @@ pub fn bg_from_video(video: &Path) -> PathBuf {
// io::stdout().write_all(&output.stdout).unwrap(); // io::stdout().write_all(&output.stdout).unwrap();
// io::stderr().write_all(&output.stderr).unwrap(); // io::stderr().write_all(&output.stderr).unwrap();
} else { } else {
println!("Screenshot already exists"); debug!("Screenshot already exists");
} }
screenshot screenshot
} }

View file

@ -27,7 +27,8 @@ mod ytdl {
use cxx_qt::{CxxQtType, Threading}; use cxx_qt::{CxxQtType, Threading};
use cxx_qt_lib::{QString, QUrl}; use cxx_qt_lib::{QString, QUrl};
use dirs; use dirs;
use std::{fs, thread, pin::Pin}; use tracing::debug;
use std::{fs, pin::Pin};
use youtube_dl::YoutubeDl; use youtube_dl::YoutubeDl;
#[derive(Clone, Default)] #[derive(Clone, Default)]
@ -47,7 +48,6 @@ impl ytdl::Ytdl {
if !url.is_valid() { if !url.is_valid() {
false false
} else { } else {
let data_dir = dirs::data_local_dir().unwrap();
if let Some(mut data_dir) = dirs::data_local_dir() { if let Some(mut data_dir) = dirs::data_local_dir() {
data_dir.push("lumina"); data_dir.push("lumina");
data_dir.push("ytdl"); data_dir.push("ytdl");
@ -55,7 +55,7 @@ impl ytdl::Ytdl {
fs::create_dir(&data_dir) fs::create_dir(&data_dir)
.expect("Could not create ytdl dir"); .expect("Could not create ytdl dir");
} }
println!("{:?}", data_dir); debug!(?data_dir);
self.as_mut().set_loading(true); self.as_mut().set_loading(true);
let thread = self.qt_thread(); let thread = self.qt_thread();
let runtime = let runtime =
@ -63,7 +63,7 @@ impl ytdl::Ytdl {
runtime.spawn(async move { runtime.spawn(async move {
let url = url.to_string(); let url = url.to_string();
let output_dirs = data_dir.to_str().unwrap(); let output_dirs = data_dir.to_str().unwrap();
println!("{output_dirs}"); debug!(output_dirs);
let ytdl = YoutubeDl::new(url) let ytdl = YoutubeDl::new(url)
.socket_timeout("15") .socket_timeout("15")
.output_directory(output_dirs) .output_directory(output_dirs)
@ -73,9 +73,7 @@ impl ytdl::Ytdl {
.unwrap(); .unwrap();
let output = let output =
ytdl.into_single_video().unwrap(); ytdl.into_single_video().unwrap();
println!("{:?}", output.title); debug!(output.title, output.thumbnail, output.url);
println!("{:?}", output.thumbnail);
println!("{:?}", output.url);
let title = QString::from(&output.title); let title = QString::from(&output.title);
let thumbnail = QUrl::from( let thumbnail = QUrl::from(
&output.thumbnail.unwrap_or_default(), &output.thumbnail.unwrap_or_default(),
@ -87,7 +85,7 @@ impl ytdl::Ytdl {
file.push_str( file.push_str(
&output.ext.unwrap_or_default(), &output.ext.unwrap_or_default(),
); );
println!("{:?}", file); debug!(file);
thread.queue(move |mut qobject_ytdl| { thread.queue(move |mut qobject_ytdl| {
qobject_ytdl.as_mut().set_loaded(true); qobject_ytdl.as_mut().set_loaded(true);