From ac57da48803221156cb031743696416cc3de8df4 Mon Sep 17 00:00:00 2001 From: vandechat96 Date: Fri, 23 Dec 2022 17:04:22 +0100 Subject: [PATCH] has better chance to find to correct song again --- src/subsonic.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/subsonic.rs b/src/subsonic.rs index 32d977b..2ce45ca 100755 --- a/src/subsonic.rs +++ b/src/subsonic.rs @@ -12,7 +12,7 @@ use regex::Regex; use thiserror::Error; lazy_static! { - static ref RE: Regex = Regex::new(r"[-()\[\];']").unwrap(); + static ref RE: Regex = Regex::new(r"[()\[\];']").unwrap(); } const SALT_SIZE: usize = 36; @@ -222,7 +222,7 @@ impl Client { let artist = &track.artist; let album = &track.album; let mut title = format!("{name} {artist} {album}"); - title = RE.replace_all(&title,"").to_string(); + // title = RE.replace_all(&title,"").to_string(); let mut found = self.search_track(title).await?; @@ -236,12 +236,9 @@ impl Client { } } - found = found - .into_iter() - .filter(|x| { + found.retain(|x| { x.title == *name && x.album == *album && x.get_artists().contains(&artist.as_str()) - }) - .collect(); + }); debug!("Found {:?}", found);