|
|
@ -161,20 +161,28 @@ fn main() -> Result<(), Error> { |
|
|
|
match event { |
|
|
|
match event { |
|
|
|
Ok(event) => { |
|
|
|
Ok(event) => { |
|
|
|
debug!("MPRIS event: {:#?}", event); |
|
|
|
debug!("MPRIS event: {:#?}", event); |
|
|
|
match &event { |
|
|
|
match event { |
|
|
|
Event::PlayerShutDown => { |
|
|
|
Event::PlayerShutDown => { |
|
|
|
info!("Player shut down"); |
|
|
|
info!("Player shut down"); |
|
|
|
break 'event_loop; |
|
|
|
break 'event_loop; |
|
|
|
} |
|
|
|
} |
|
|
|
Event::TrackChanged(metadata) => { |
|
|
|
Event::TrackChanged(mut metadata) => { |
|
|
|
let title = metadata.title().unwrap_or(""); |
|
|
|
let mut title = metadata.title().unwrap_or(""); |
|
|
|
info!("--- new track : {} ---", title); |
|
|
|
info!("--- new track : {} ---", title); |
|
|
|
debug!("{:#?}", event); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if title.is_empty() { |
|
|
|
if title.is_empty() { |
|
|
|
warn!("!!! Spotify is giving us garbage - empty metadata struct !!!"); |
|
|
|
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(); |
|
|
|
let mut artists = HashSet::new(); |
|
|
|