In a program I am trying to display the artwork of my currently playing spotify song using rust.
The code only works if I copy and paste the url into the argument, so I tried making a variable called arturl to use in a .arg(arturl). But that makes the code return nothing, and the arturl variable does return the correct value.
My code:
use std::process::{Command, Stdio};
fn main() {
let arturl = Command::new("playerctl")
.arg("metadata")
.arg("mpris:artUrl")
.stdout(Stdio::piped())
.output()
.expect("url failed");
let arturl = String::from_utf8(arturl.stdout).unwrap();
let picture = Command::new("chafa")
.arg("--size=30")
.arg(arturl)
.stdout(Stdio::piped())
.output()
.expect("picture failed");
let picture = String::from_utf8(picture.stdout).unwrap();
println!("{}", picture);
}
println!("{:?}", arturl)(exactly this, with Debug formatting, to see possible unprintable symbols)?