about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-16 10:17:43 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-16 10:17:43 +0200
commitc0a3b61fb344a5ca86cae1c31d2e42fbe56b6726 (patch)
treed18ed0a7bfd8289e55d1a58673544f1fdf33eb7e
parentfix(yt/download/get_file_size): Correct deal with `filesize_approx` = Null (diff)
downloadyt-c0a3b61fb344a5ca86cae1c31d2e42fbe56b6726.zip
feat(yt/videos/list): Replace the nucleo matcher with a simple `contains`
The matching behaviour was not predictable at all (probably due to a bad
config), which than led to using `yt videos ls | grep -i <query>`
instead.
Diffstat (limited to '')
-rw-r--r--crates/yt/Cargo.toml1
-rw-r--r--crates/yt/src/videos/mod.rs21
2 files changed, 4 insertions, 18 deletions
diff --git a/crates/yt/Cargo.toml b/crates/yt/Cargo.toml
index 6803e68..100eb29 100644
--- a/crates/yt/Cargo.toml
+++ b/crates/yt/Cargo.toml
@@ -30,7 +30,6 @@ chrono = { version = "0.4.41", features = ["now"] }
 chrono-humanize = "0.2.3"
 clap = { version = "4.5.40", features = ["derive"] }
 futures = "0.3.31"
-nucleo-matcher = "0.3.1"
 owo-colors = "4.2.1"
 regex = "1.11.1"
 sqlx = { version = "0.8.6", features = ["runtime-tokio", "sqlite"] }
diff --git a/crates/yt/src/videos/mod.rs b/crates/yt/src/videos/mod.rs
index e821772..960340b 100644
--- a/crates/yt/src/videos/mod.rs
+++ b/crates/yt/src/videos/mod.rs
@@ -11,10 +11,6 @@
 
 use anyhow::Result;
 use futures::{TryStreamExt, stream::FuturesUnordered};
-use nucleo_matcher::{
-    Matcher,
-    pattern::{CaseMatching, Normalization, Pattern},
-};
 
 pub mod display;
 
@@ -46,19 +42,10 @@ pub async fn query(app: &App, limit: Option<usize>, search_query: Option<String>
         .await?;
 
     if let Some(query) = search_query {
-        let mut matcher = Matcher::new(nucleo_matcher::Config::DEFAULT.match_paths());
-
-        let pattern_matches = Pattern::parse(
-            &query.replace(' ', "\\ "),
-            CaseMatching::Ignore,
-            Normalization::Smart,
-        )
-        .match_list(all_video_strings, &mut matcher);
-
-        pattern_matches
-            .iter()
-            .rev()
-            .for_each(|(val, key)| println!("{val} ({key})"));
+        all_video_strings
+            .into_iter()
+            .filter(|video| video.to_lowercase().contains(&query.to_lowercase()))
+            .for_each(|video| println!("{video}"));
     } else {
         println!("{}", all_video_strings.join("\n"));
     }