diff --git a/src/main.rs b/src/main.rs index 19d7c31..4e5ee28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,7 +84,7 @@ async fn main() -> Result<(), Box> { } if config.jellyfin.blacklist.is_some() { let blacklist = config.jellyfin.blacklist.clone().unwrap(); - blacklist.media_types.and_then(|media_types| { + if let Some(media_types) = blacklist.media_types { println!( "{} {}", "These media types won't be shown:".bold().red(), @@ -95,18 +95,16 @@ async fn main() -> Result<(), Box> { .join(", ") .bold() .red() - ); - Some(media_types) - }); + ) + } - blacklist.libraries.and_then(|libraries| { + if let Some(libraries) = blacklist.libraries { println!( "{} {}", "These media libraries won't be shown:".bold().red(), libraries.join(", ").bold().red() - ); - Some(libraries) - }); + ) + } } let mut connected: bool = false; @@ -144,7 +142,7 @@ async fn main() -> Result<(), Box> { .iter() .for_each(|x| { if blacklist_check && !content.media_type.is_none() { - blacklist_check = content.media_type != x.to_owned() + blacklist_check = content.media_type != *x } }); if config @@ -222,6 +220,8 @@ async fn main() -> Result<(), Box> { .and_then(|discord| discord.buttons) .unwrap_or(vec![default_button.clone(), default_button]); + #[allow(clippy::needless_range_loop)] + // Allowing needless range loop because button.name and button.url gets dropped too early otherwise for i in 0..buttons.len() { if buttons[i].name == "dynamic" && buttons[i].url == "dynamic" diff --git a/src/services/jellyfin.rs b/src/services/jellyfin.rs index fd7fb85..30d7ac5 100644 --- a/src/services/jellyfin.rs +++ b/src/services/jellyfin.rs @@ -201,7 +201,7 @@ impl Content { { Some(Display::Vec(music)) => music, Some(Display::String(music)) => music - .split(",") + .split(',') .map(|d| d.trim().to_string()) .collect::>(), _ => vec![String::from("genres")], @@ -267,7 +267,8 @@ impl Content { content.item_id(now_playing_item["ParentId"].as_str().unwrap().to_string()); content.details(now_playing_item["Album"].as_str().unwrap_or(name).into()); - let raw_artists = now_playing_item["Artists"].as_array() + let raw_artists = now_playing_item["Artists"] + .as_array() .unwrap() .iter() .map(|a| a.as_str().unwrap().to_string()) @@ -280,13 +281,12 @@ impl Content { artists += &raw_artists[i]; } else if raw_artists.len() != 1 { artists += &format!(" and {}", raw_artists[i]); - break + break; } else { artists += &raw_artists[i]; - break + break; } artists.push_str(", ") - } let mut genres = "".to_string(); @@ -305,7 +305,7 @@ impl Content { .collect::>() .join(", "), ) - }, + } }; content.state_message(format!("By {}{}", artists, genres))