Skip to content

Commit

Permalink
fmt and clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Radiicall committed Jul 22, 2023
1 parent fadc4db commit 90d5725
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
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(),
Expand All @@ -95,18 +95,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.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;
Expand Down Expand Up @@ -144,7 +142,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.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
Expand Down Expand Up @@ -222,6 +220,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.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"
Expand Down
12 changes: 6 additions & 6 deletions src/services/jellyfin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>(),
_ => vec![String::from("genres")],
Expand Down Expand Up @@ -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())
Expand All @@ -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();
Expand All @@ -305,7 +305,7 @@ impl Content {
.collect::<Vec<String>>()
.join(", "),
)
},
}
};

content.state_message(format!("By {}{}", artists, genres))
Expand Down

0 comments on commit 90d5725

Please sign in to comment.