From a1036aa059495b76b06319c7e6b6ac52150c9921 Mon Sep 17 00:00:00 2001 From: Collins Muriuki Date: Thu, 19 Sep 2024 11:38:21 +0300 Subject: [PATCH] Fix clippy warnings --- ytdlp_bindings/src/file_types/vtt.rs | 2 +- ytdlp_bindings/src/ytldp.rs | 6 +++--- ytparse_cron/src/error.rs | 1 + ytparse_cron/src/parser.rs | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ytdlp_bindings/src/file_types/vtt.rs b/ytdlp_bindings/src/file_types/vtt.rs index c965927..d3fcda5 100644 --- a/ytdlp_bindings/src/file_types/vtt.rs +++ b/ytdlp_bindings/src/file_types/vtt.rs @@ -103,7 +103,7 @@ pub fn parse_vtt_content(content: &str) -> Vec { let end_time = times[1].trim().to_string(); let mut text = String::new(); - while let Some(text_line) = lines.next() { + for text_line in lines.by_ref() { if text_line.is_empty() { break; } diff --git a/ytdlp_bindings/src/ytldp.rs b/ytdlp_bindings/src/ytldp.rs index aa24e4d..dd9c15e 100644 --- a/ytdlp_bindings/src/ytldp.rs +++ b/ytdlp_bindings/src/ytldp.rs @@ -271,7 +271,7 @@ mod tests { ytdlp.download_auto_sub( "https://www.youtube.com/watch?v=p1OqRc15K3o", - &output_pattern, + output_pattern, )?; // Use glob to find the downloaded file @@ -308,7 +308,7 @@ mod tests { let temp_dir = tempdir().expect("Failed to create temp directory"); let output_template = temp_dir.path().join("%(title)s.%(ext)s"); - let result = ytdlp.download_video(TEST_VIDEO_URL, &output_template); + let result = ytdlp.download_video(TEST_VIDEO_URL, output_template); assert!( result.is_ok(), @@ -377,7 +377,7 @@ mod tests { let temp_dir = tempdir().expect("Failed to create temp directory"); let output_template = temp_dir.path().join("%(playlist_index)s-%(title)s.%(ext)s"); - let result = ytdlp.download_playlist(TEST_PLAYLIST_URL, &output_template); + let result = ytdlp.download_playlist(TEST_PLAYLIST_URL, output_template); assert!( result.is_ok(), diff --git a/ytparse_cron/src/error.rs b/ytparse_cron/src/error.rs index fc2f948..e011109 100644 --- a/ytparse_cron/src/error.rs +++ b/ytparse_cron/src/error.rs @@ -1,3 +1,4 @@ +#[allow(clippy::enum_variant_names)] #[derive(thiserror::Error, Debug)] pub enum Error { #[error("ParseError: {0}")] diff --git a/ytparse_cron/src/parser.rs b/ytparse_cron/src/parser.rs index f3cc513..26ae972 100644 --- a/ytparse_cron/src/parser.rs +++ b/ytparse_cron/src/parser.rs @@ -29,7 +29,7 @@ pub fn parse_streams(json: &Value) -> Result, Error> { if let Some(contents) = json["contents"]["twoColumnBrowseResultsRenderer"]["tabs"] .get(2) .ok_or(Error::ParseError("Failed to get item at idx 2 from ytInitialData['contents']['twoColumnBrowseResultsRenderer']['tabs']")) - .and_then(|tab| Ok(tab["tabRenderer"]["content"]["richGridRenderer"]["contents"].as_array()))? + .map(|tab| tab["tabRenderer"]["content"]["richGridRenderer"]["contents"].as_array())? { for item in contents { if let Ok(video_renderer) =