From 578d2b2f0c3f4900c9da2a9757322f07ac153356 Mon Sep 17 00:00:00 2001 From: Bettehem Date: Tue, 14 Jul 2020 22:30:14 +0300 Subject: [PATCH] fix mpris metadata returing Spotify URI instead of an url in xesam:url field (#222) * Added OpenUri D-BUS MPRIS support. Removed "user:" from URIType check because Spotify doesn't always provide it. * Added tags to .gitignore * Changed mpris metadata to actually return the track's url instead of the Spotify URI so that it matches the functionality of the official Spotify client. * Changed mpris:trackid and xesam:url to not use static naming so it can support podcasts. * Changed xesam:url to default to an empty string instead of "0" --- .gitignore | 2 ++ src/mpris.rs | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index e186719..c1e281b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ **/*.rs.bk *.log + +tags diff --git a/src/mpris.rs b/src/mpris.rs index 11682bc..52a1187 100644 --- a/src/mpris.rs +++ b/src/mpris.rs @@ -37,10 +37,7 @@ fn get_metadata(playable: Option) -> Metadata { Variant(Box::new( playable .map(|t| { - format!( - "spotify:track:{}", - t.id().unwrap_or_else(|| "0".to_string()) - ) + t.uri() }) .unwrap_or_default(), )), @@ -118,7 +115,13 @@ fn get_metadata(playable: Option) -> Metadata { ); hm.insert( "xesam:url".to_string(), - Variant(Box::new(playable.map(|t| t.uri()).unwrap_or_default())), + Variant(Box::new( + playable + .map(|t| { + t.share_url().unwrap_or_default() + }) + .unwrap_or_default(), + )), ); hm