about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-28 17:08:17 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-28 17:08:17 +0200
commitc5ad75c9176990da906c9ef3086e8efe25037fd9 (patch)
tree943f88a2d62a6f56cdb8bde32c9ad528c3305423
parentfix(yt/{subscribe,storage/subscriptions}): Fix more instances of the capitali... (diff)
downloadyt-c5ad75c9176990da906c9ef3086e8efe25037fd9.zip
fix(yt/subscribe): Don't hard-error on failed subscribe, if it was not specified
The user did not specify to subscribe to the `videos`, `streams` and
`shorts` variants, as such we should not error if one of them fails, as
the other one could succeed.
-rw-r--r--crates/yt/src/subscribe/mod.rs25
1 files changed, 17 insertions, 8 deletions
diff --git a/crates/yt/src/subscribe/mod.rs b/crates/yt/src/subscribe/mod.rs
index ad074fb..66797e8 100644
--- a/crates/yt/src/subscribe/mod.rs
+++ b/crates/yt/src/subscribe/mod.rs
@@ -13,7 +13,7 @@ use std::str::FromStr;
 
 use anyhow::{Context, Result, bail};
 use futures::FutureExt;
-use log::warn;
+use log::{error, warn};
 use tokio::io::{AsyncBufRead, AsyncBufReadExt};
 use url::Url;
 use yt_dlp::{json_cast, json_get, options::YoutubeDLOptions};
@@ -121,17 +121,26 @@ pub async fn subscribe(app: &App, name: Option<String>, url: Url) -> Result<()>
 
             out?;
         } else {
-            actual_subscribe(app, None, url.join("videos/").unreachable("See above."))
+            let _ = actual_subscribe(app, None, url.join("videos/").unreachable("See above."))
                 .await
-                .with_context(|| format!("Failed to subscribe to the '{}' variant", "{Videos}"))?;
+                .map_err(|err| {
+                    error!("Failed to subscribe to the '{}' variant: {err}", "{Videos}");
+                });
 
-            actual_subscribe(app, None, url.join("streams/").unreachable("See above."))
+            let _ = actual_subscribe(app, None, url.join("streams/").unreachable("See above."))
                 .await
-                .with_context(|| format!("Failed to subscribe to the '{}' variant", "{Streams}"))?;
-
-            actual_subscribe(app, None, url.join("shorts/").unreachable("See above."))
+                .map_err(|err| {
+                    error!(
+                        "Failed to subscribe to the '{}' variant: {err}",
+                        "{Streams}"
+                    );
+                });
+
+            let _ = actual_subscribe(app, None, url.join("shorts/").unreachable("See above."))
                 .await
-                .with_context(|| format!("Failed to subscribe to the '{}' variant", "{Shorts}"))?;
+                .map_err(|err| {
+                    error!("Failed to subscribe to the '{}' variant: {err}", "{Shorts}");
+                });
         }
     } else {
         actual_subscribe(app, name, url).await?;