aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-28 16:03:21 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-28 16:03:21 +0200
commit247dabc7905d9deecc86ac11404b5665042c60f1 (patch)
treef012c68904857f3944d642d5c66e06fc9e0fdcb1
parentfix(yt/download/progress_hook): Remove superfluous apostrophes (diff)
downloadyt-247dabc7905d9deecc86ac11404b5665042c60f1.zip
fix(yt/select/cmds/add): Don't print the title as value, cast it first
Otherwise, we would silently ignore an invalid type, if the title type ever changes.
-rw-r--r--crates/yt/src/select/cmds/add.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/yt/src/select/cmds/add.rs b/crates/yt/src/select/cmds/add.rs
index 2fff298..68fd558 100644
--- a/crates/yt/src/select/cmds/add.rs
+++ b/crates/yt/src/select/cmds/add.rs
@@ -48,6 +48,7 @@ pub(super) async fn add(
let hashes = get_all_hashes(app)
.await
.context("Failed to fetch all video hashes")?;
+
let extractor_hash = blake3::hash(json_get!(entry, "id", as_str).as_bytes());
if hashes.contains(&extractor_hash) {
error!(
@@ -61,9 +62,10 @@ pub(super) async fn add(
.get("url")
.map_or("<Unknown video Url>".to_owned(), ToString::to_string)
))?,
- entry
- .get("title")
- .map_or(String::new(), |title| format!(" ('{title}')"))
+ entry.get("title").map_or(String::new(), |title| format!(
+ " (\"{}\")",
+ json_cast!(title, as_str)
+ ))
);
return Ok(());
}