Use raw strings for mpd commands
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Sijmen 2023-05-16 02:03:06 +02:00
parent 9dfa38225f
commit dae598e15c
Signed by: vijfhoek
GPG Key ID: DAF7821E067D9C48
1 changed files with 7 additions and 4 deletions

View File

@ -198,7 +198,7 @@ impl Mpd {
pub async fn add_pos(&mut self, path: &str, pos: &str) -> anyhow::Result<()> { pub async fn add_pos(&mut self, path: &str, pos: &str) -> anyhow::Result<()> {
let path = Self::escape_str(path); let path = Self::escape_str(path);
let pos = Self::escape_str(pos); let pos = Self::escape_str(pos);
self.command(&format!("add \"{path}\" \"{pos}\"")).await?; self.command(&format!(r#"add "{path}" "{pos}""#)).await?;
Ok(()) Ok(())
} }
@ -221,7 +221,9 @@ impl Mpd {
pub async fn albumart(&mut self, path: &str) -> anyhow::Result<Vec<u8>> { pub async fn albumart(&mut self, path: &str) -> anyhow::Result<Vec<u8>> {
let path = Self::escape_str(path); let path = Self::escape_str(path);
let result = self.command_binary(&format!("albumart \"{path}\"")).await?; let result = self
.command_binary(&format!(r#"albumart "{path}""#))
.await?;
match result.binary { match result.binary {
Some(binary) => Ok(binary), Some(binary) => Ok(binary),
@ -232,7 +234,7 @@ impl Mpd {
pub async fn readpicture(&mut self, path: &str) -> anyhow::Result<Vec<u8>> { pub async fn readpicture(&mut self, path: &str) -> anyhow::Result<Vec<u8>> {
let path = Self::escape_str(path); let path = Self::escape_str(path);
let result = self let result = self
.command_binary(&format!("readpicture \"{path}\"")) .command_binary(&format!(r#"readpicture "{path}""#))
.await?; .await?;
match result.binary { match result.binary {
@ -250,8 +252,9 @@ impl Mpd {
.unwrap_or("n/a".to_string()) .unwrap_or("n/a".to_string())
} }
let path = Self::escape_str(path);
let result = self let result = self
.command(&format!("lsinfo \"{}\"", Self::escape_str(path))) .command(&format!(r#"lsinfo "{path}""#))
.await? .await?
.into_hashmaps(&["file", "directory", "playlist"]); .into_hashmaps(&["file", "directory", "playlist"]);