aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-15 18:27:19 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-15 18:27:19 +0200
commitb6a57c5cad1ee7df56dad5ccb2317f936e682bbe (patch)
tree57481b9e165a848b0dda48ca5089b1f450fe19c5
parentfeat(yt/update): Print a nice progress number (diff)
downloadyt-b6a57c5cad1ee7df56dad5ccb2317f936e682bbe.zip
fix(yt/update/video_entry_to_video): Cast the json objects
Otherwise, we might encounter very weird behaviour if yt_dlp ever changes the types of these keys.
Diffstat (limited to '')
-rw-r--r--crates/yt/src/update/mod.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/yt/src/update/mod.rs b/crates/yt/src/update/mod.rs
index a25c233..36c8c81 100644
--- a/crates/yt/src/update/mod.rs
+++ b/crates/yt/src/update/mod.rs
@@ -147,13 +147,15 @@ pub fn video_entry_to_video(entry: &InfoJson, sub: Option<&Subscription>) -> Res
let subscription_name = if let Some(sub) = sub {
Some(sub.name.clone())
- } else if let Some(uploader) = entry.get("uploader") {
- if entry.get("webpage_url_domain")
- == Some(&serde_json::Value::String("youtube.com".to_owned()))
+ } else if let Some(uploader) = entry.get("uploader").map(|val| json_cast!(val, as_str)) {
+ if entry
+ .get("webpage_url_domain")
+ .map(|val| json_cast!(val, as_str))
+ == Some("youtube.com")
{
Some(format!("{uploader} - Videos"))
} else {
- Some(json_cast!(uploader, as_str).to_owned())
+ Some(uploader.to_owned())
}
} else {
None