From c5ad75c9176990da906c9ef3086e8efe25037fd9 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 28 Jun 2025 17:08:17 +0200 Subject: 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. --- crates/yt/src/subscribe/mod.rs | 25 +++++++++++++++++-------- 1 file 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, 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?; -- cgit 1.4.1