|
@@ -13,16 +13,19 @@ impl Block for Music {
|
|
|
|
|
|
match player {
|
|
match player {
|
|
Ok(player) => {
|
|
Ok(player) => {
|
|
- let meta = player.get_metadata().expect("Could not get metadata");
|
|
|
|
- let artist: String = meta
|
|
|
|
- .artists()
|
|
|
|
- .map(|a| a.into_iter().intersperse(", ").collect())
|
|
|
|
- .unwrap_or("".to_string());
|
|
|
|
- let track: String = meta
|
|
|
|
- .title()
|
|
|
|
- .map(|a| a.to_string())
|
|
|
|
- .unwrap_or("".to_string());
|
|
|
|
- format!("{} - {}", artist, track)
|
|
|
|
|
|
+ if let Ok(meta) = player.get_metadata() {
|
|
|
|
+ let artist: String = meta
|
|
|
|
+ .artists()
|
|
|
|
+ .map(|a| a.into_iter().intersperse(", ").collect())
|
|
|
|
+ .unwrap_or("".to_string());
|
|
|
|
+ let track: String = meta
|
|
|
|
+ .title()
|
|
|
|
+ .map(|a| a.to_string())
|
|
|
|
+ .unwrap_or("".to_string());
|
|
|
|
+ format!("{} - {}", artist, track)
|
|
|
|
+ } else {
|
|
|
|
+ "".to_string()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
Err(e) => {
|
|
Err(e) => {
|
|
println!("{:?}", e);
|
|
println!("{:?}", e);
|