From 013273b832387aa9e3818b3abca97956342e73a9 Mon Sep 17 00:00:00 2001 From: bytedream Date: Sun, 10 Mar 2024 13:40:16 +0100 Subject: [PATCH] Format code --- crunchy-cli-core/src/archive/command.rs | 2 +- crunchy-cli-core/src/archive/filter.rs | 2 +- crunchy-cli-core/src/utils/download.rs | 20 +++++++++----------- crunchy-cli-core/src/utils/parse.rs | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/crunchy-cli-core/src/archive/command.rs b/crunchy-cli-core/src/archive/command.rs index 600065a..8258b36 100644 --- a/crunchy-cli-core/src/archive/command.rs +++ b/crunchy-cli-core/src/archive/command.rs @@ -593,7 +593,7 @@ fn get_video_streams(path: &Path) -> Result, Vec)>> .stdout(Stdio::null()) .stderr(Stdio::piped()) .arg("-hide_banner") - .args(["-i", &path.to_string_lossy().to_string()]) + .args(["-i", &path.to_string_lossy()]) .output()?; let ffmpeg_output = String::from_utf8(ffmpeg.stderr)?; diff --git a/crunchy-cli-core/src/archive/filter.rs b/crunchy-cli-core/src/archive/filter.rs index 2a47738..90ab373 100644 --- a/crunchy-cli-core/src/archive/filter.rs +++ b/crunchy-cli-core/src/archive/filter.rs @@ -180,7 +180,7 @@ impl Filter for ArchiveFilter { Some( season .audio_locales - .get(0) + .first() .cloned() .unwrap_or(Locale::ja_JP), ) diff --git a/crunchy-cli-core/src/utils/download.rs b/crunchy-cli-core/src/utils/download.rs index f3dc631..7f81bc9 100644 --- a/crunchy-cli-core/src/utils/download.rs +++ b/crunchy-cli-core/src/utils/download.rs @@ -793,7 +793,7 @@ impl Downloader { .await? .bytes() .await?; - fs::write(&file, font.to_vec())?; + fs::write(&file, font)?; Ok(Some((file, false))) } @@ -990,20 +990,18 @@ fn get_video_stats(path: &Path) -> Result<(NaiveTime, f64)> { .args(["-i", path.to_str().unwrap()]) .output()?; let ffmpeg_output = String::from_utf8(ffmpeg.stderr)?; - let length_caps = video_length.captures(ffmpeg_output.as_str()).map_or( - Err(anyhow::anyhow!( + let length_caps = video_length + .captures(ffmpeg_output.as_str()) + .ok_or(anyhow::anyhow!( "failed to get video length: {}", ffmpeg_output - )), - Ok, - )?; - let fps_caps = video_fps.captures(ffmpeg_output.as_str()).map_or( - Err(anyhow::anyhow!( + ))?; + let fps_caps = video_fps + .captures(ffmpeg_output.as_str()) + .ok_or(anyhow::anyhow!( "failed to get video fps: {}", ffmpeg_output - )), - Ok, - )?; + ))?; Ok(( NaiveTime::parse_from_str(length_caps.name("time").unwrap().as_str(), "%H:%M:%S%.f") diff --git a/crunchy-cli-core/src/utils/parse.rs b/crunchy-cli-core/src/utils/parse.rs index 70cbfbb..2c4a53b 100644 --- a/crunchy-cli-core/src/utils/parse.rs +++ b/crunchy-cli-core/src/utils/parse.rs @@ -147,7 +147,7 @@ pub async fn parse_url( url = crunchy.client().get(&url).send().await?.url().to_string() } - let parsed_url = crunchyroll_rs::parse_url(url).map_or(Err(anyhow!("Invalid url")), Ok)?; + let parsed_url = crunchyroll_rs::parse_url(url).ok_or(anyhow!("Invalid url"))?; debug!("Url type: {:?}", parsed_url); let media_collection = match parsed_url { UrlType::Series(id)