From e4c54dc6f577030a9848c5b2b222f64de2c44786 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Thu, 21 Nov 2024 22:23:50 +0100 Subject: [PATCH] ununwrap --- src/mpris/player.rs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/mpris/player.rs b/src/mpris/player.rs index b36c111..25a1c7f 100644 --- a/src/mpris/player.rs +++ b/src/mpris/player.rs @@ -4,7 +4,7 @@ use gtk::glib::SendWeakRef; use std::collections::HashMap; use tracing::{event, Level}; use zbus::object_server::{InterfaceRef, SignalEmitter}; -use zbus::zvariant::{ObjectPath, OwnedValue, Value}; +use zbus::zvariant::{ObjectPath, Value}; pub const MICROSECONDS: f64 = 1e6; // in a second @@ -153,21 +153,17 @@ impl Player { } #[zbus(property)] - fn metadata(&self) -> HashMap<&'static str, OwnedValue> { + fn metadata(&self) -> HashMap<&'static str, Value<'_>> { let mut map = HashMap::new(); if let Some(song) = self.window().song() { map.insert( "mpris:trackid", - Value::new(format!("/eu/callcc/audrey/Track/{}", song.counter())) - .try_into() - .unwrap(), + Value::new(format!("/eu/callcc/audrey/Track/{}", song.counter())).to_owned(), ); map.insert( "mpris:length", - Value::new((self.window().duration() * MICROSECONDS) as i64) - .try_into() - .unwrap(), + Value::new((self.window().duration() * MICROSECONDS) as i64), ); map.insert( "mpris:artUrl", @@ -176,15 +172,12 @@ impl Player { .unwrap() .to_string(), ) - .try_into() - .unwrap(), + .to_owned(), ); - map.insert("xesam:album", Value::new(song.album()).try_into().unwrap()); - map.insert( - "xesam:artist", - Value::new(vec![song.artist()]).try_into().unwrap(), - ); - map.insert("xesam:title", Value::new(song.title()).try_into().unwrap()); + map.insert("xesam:album", Value::new(song.album())); + // TODO: use the right opensubsonic data + map.insert("xesam:artist", Value::new(vec![song.artist()])); + map.insert("xesam:title", Value::new(song.title())); } map