diff --git a/src/files.rs b/src/files.rs index cf31277..684cbfb 100644 --- a/src/files.rs +++ b/src/files.rs @@ -19,14 +19,14 @@ use log::{debug, error, info, trace}; use crate::data::{Claims, FilesRequest, FilterMode, PhotosResponse, SortType}; use crate::{create_thumbnails, AppState}; -use crate::data::SortType::{NameAsc}; +use crate::data::SortType::NameAsc; use crate::error::IntoHttpError; use crate::tags::TagDao; +use crate::video::actors::StreamActor; use path_absolutize::*; use rand::prelude::SliceRandom; use rand::thread_rng; use serde::Deserialize; -use crate::video::actors::StreamActor; pub async fn list_photos( _: Claims, @@ -396,10 +396,7 @@ mod tests { if self.err { Err(anyhow!("Error for test")) } else if let Some(files) = self.files.get(path) { - Ok(files - .iter() - .map(PathBuf::from) - .collect::>()) + Ok(files.iter().map(PathBuf::from).collect::>()) } else { Ok(Vec::new()) } diff --git a/src/state.rs b/src/state.rs index b3ad608..7497285 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,6 +1,6 @@ +use crate::video::actors::{PlaylistGenerator, StreamActor, VideoPlaylistManager}; use actix::{Actor, Addr}; use std::{env, sync::Arc}; -use crate::video::actors::{PlaylistGenerator, StreamActor, VideoPlaylistManager}; pub struct AppState { pub stream_manager: Arc>, diff --git a/src/testhelpers.rs b/src/testhelpers.rs index e288716..66c1ac2 100644 --- a/src/testhelpers.rs +++ b/src/testhelpers.rs @@ -48,10 +48,7 @@ impl UserDao for TestUserDao { } fn user_exists(&mut self, user: &str) -> bool { - self.user_map - .borrow() - .iter() - .any(|u| u.username == user) + self.user_map.borrow().iter().any(|u| u.username == user) } } diff --git a/src/video/ffmpeg.rs b/src/video/ffmpeg.rs index 61c1b5c..080af0d 100644 --- a/src/video/ffmpeg.rs +++ b/src/video/ffmpeg.rs @@ -10,7 +10,7 @@ use tokio::process::Command; pub struct Ffmpeg; impl Ffmpeg { - async fn generate_playlist(&self, input_file: &str, output_file: &str) -> Result { + async fn _generate_playlist(&self, input_file: &str, output_file: &str) -> Result { let ffmpeg_result: Result = tokio::process::Command::new("ffmpeg") .arg("-i") .arg(input_file) @@ -43,10 +43,10 @@ impl Ffmpeg { async fn get_video_duration(&self, input_file: &str) -> Result { Command::new("ffprobe") - .args(&["-i", input_file]) - .args(&["-show_entries", "format=duration"]) - .args(&["-v", "quiet"]) - .args(&["-of", "csv=p=0"]) + .args(["-i", input_file]) + .args(["-show_entries", "format=duration"]) + .args(["-v", "quiet"]) + .args(["-of", "csv=p=0"]) .output() .await .map(|out| String::from_utf8_lossy(&out.stdout).trim().to_string()) @@ -73,9 +73,9 @@ impl Ffmpeg { debug!("Creating gif frames for '{}'", input_file); Command::new("ffmpeg") - .args(&["-i", input_file]) - .args(&["-vf", &format!("fps=20/{}", duration)]) - .args(&["-q:v", "2"]) + .args(["-i", input_file]) + .args(["-vf", &format!("fps=20/{}", duration)]) + .args(["-q:v", "2"]) .stderr(Stdio::null()) .arg(format!("{}/frame_%03d.jpg", temp_path)) .status() @@ -84,9 +84,9 @@ impl Ffmpeg { debug!("Generating palette"); Command::new("ffmpeg") - .args(&["-i", &format!("{}/frame_%03d.jpg", temp_path)]) - .args(&["-vf", "palettegen"]) - .arg(&format!("{}/palette.png", temp_path)) + .args(["-i", &format!("{}/frame_%03d.jpg", temp_path)]) + .args(["-vf", "palettegen"]) + .arg(format!("{}/palette.png", temp_path)) .stderr(Stdio::null()) .status() }) @@ -117,15 +117,15 @@ impl Ffmpeg { async fn create_gif_from_frames(&self, frame_base_dir: &str, output_file: &str) -> Result { Command::new("ffmpeg") .arg("-y") - .args(&["-framerate", "4"]) - .args(&["-i", &format!("{}/frame_%03d.jpg", frame_base_dir)]) - .args(&["-i", &format!("{}/palette.png", frame_base_dir)]) - .args(&[ + .args(["-framerate", "4"]) + .args(["-i", &format!("{}/frame_%03d.jpg", frame_base_dir)]) + .args(["-i", &format!("{}/palette.png", frame_base_dir)]) + .args([ "-filter_complex", // Scale to 480x480 with a center crop "[0:v]scale=480:-1:flags=lanczos,crop='min(in_w,in_h)':'min(in_w,in_h)':(in_w-out_w)/2:(in_h-out_h)/2, paletteuse", ]) - .args(&["-loop", "0"]) // loop forever + .args(["-loop", "0"]) // loop forever .arg(output_file) .stderr(Stdio::null()) .status() diff --git a/src/video/mod.rs b/src/video/mod.rs index cbbc7b6..c3c0586 100644 --- a/src/video/mod.rs +++ b/src/video/mod.rs @@ -1,2 +1,2 @@ pub mod actors; -pub mod ffmpeg; \ No newline at end of file +pub mod ffmpeg;