|
|
|
@ -161,20 +161,28 @@ fn main() -> Result<(), Error> { |
|
|
|
|
match event { |
|
|
|
|
Ok(event) => { |
|
|
|
|
debug!("MPRIS event: {:#?}", event); |
|
|
|
|
match &event { |
|
|
|
|
match event { |
|
|
|
|
Event::PlayerShutDown => { |
|
|
|
|
info!("Player shut down"); |
|
|
|
|
break 'event_loop; |
|
|
|
|
} |
|
|
|
|
Event::TrackChanged(metadata) => { |
|
|
|
|
let title = metadata.title().unwrap_or(""); |
|
|
|
|
Event::TrackChanged(mut metadata) => { |
|
|
|
|
let mut title = metadata.title().unwrap_or(""); |
|
|
|
|
info!("--- new track : {} ---", title); |
|
|
|
|
debug!("{:#?}", event); |
|
|
|
|
|
|
|
|
|
if title.is_empty() { |
|
|
|
|
warn!("!!! Spotify is giving us garbage - empty metadata struct !!!"); |
|
|
|
|
// wait for next event
|
|
|
|
|
continue 'event_loop; |
|
|
|
|
|
|
|
|
|
::std::thread::sleep(Duration::from_millis(250)); |
|
|
|
|
metadata = player.get_metadata().unwrap_or(metadata); |
|
|
|
|
title = metadata.title().unwrap_or(""); |
|
|
|
|
info!("After metadata reload -> new track : {}", title); |
|
|
|
|
|
|
|
|
|
if title.is_empty() { |
|
|
|
|
// wait for next event
|
|
|
|
|
warn!("Still bad"); |
|
|
|
|
continue 'event_loop; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let mut artists = HashSet::new(); |
|
|
|
|