Add album art to mpris d-bus info

This commit is contained in:
NGnius (Graham) 2022-10-26 20:50:45 -04:00
parent d264b84c90
commit 15c42e6654
2 changed files with 14 additions and 10 deletions

View file

@ -6,7 +6,7 @@ license = "LGPL-2.1-only OR GPL-3.0-only"
readme = "README.md" readme = "README.md"
[dependencies] [dependencies]
rodio = { version = "^0.15", features = ["symphonia-all"]} rodio = { version = "^0.16", features = ["symphonia-all"]}
m3u8-rs = { version = "^3.0" } m3u8-rs = { version = "^3.0" }
fluent-uri = { version = "^0.1" } fluent-uri = { version = "^0.1" }
mpd = { version = "0.0.12", optional = true } mpd = { version = "0.0.12", optional = true }

View file

@ -203,22 +203,26 @@ impl SystemControlWrapper {
fn build_metadata(item: Item) -> Metadata { fn build_metadata(item: Item) -> Metadata {
let file_uri = item.field("filename").and_then(|x| x.to_owned().to_str()); let file_uri = item.field("filename").and_then(|x| x.to_owned().to_str());
Metadata { Metadata {
length: None, length: None, // populated separately
art_url: None, //file_uri.clone() TODO do this without having to rip the art image from the file like Elisa art_url: item.field("cover")
.and_then(|x| x.to_owned().to_str()),
album: item.field("album").and_then(|x| x.to_owned().to_str()), album: item.field("album").and_then(|x| x.to_owned().to_str()),
album_artist: item album_artist: item
.field("albumartist") .field("albumartist")
.map( .and_then(|x| x.to_owned().to_str())
|x| x.to_owned() .map(|x| x.split(",").map(|s| s.trim().to_owned()).collect()),
.to_str()
.map(|x2| vec![x2])
).flatten(),
artist: item artist: item
.field("artist") .field("artist")
.and_then(|x| x.to_owned().to_str()) .and_then(|x| x.to_owned().to_str())
.map(|x| x.split(",").map(|s| s.trim().to_owned()).collect()), .map(|x| x.split(",").map(|s| s.trim().to_owned()).collect()),
composer: None, composer: item
disc_number: None, .field("composer")
.and_then(|x| x.to_owned().to_str())
.map(|x| x.split(",").map(|s| s.trim().to_owned()).collect()),
disc_number: item
.field("disc")
.and_then(|x| x.to_owned().to_i64())
.map(|track| track as i32),
genre: item genre: item
.field("genre") .field("genre")
.and_then(|x| x.to_owned().to_str()) .and_then(|x| x.to_owned().to_str())