From a2015b82eeb1dde1aded82435b3f3700232b9d83 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 22 Aug 2024 14:26:15 +0200 Subject: fix(subscriptions/add): Ignore the trailing slash on URLs --- src/subscribe/mod.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/subscribe') diff --git a/src/subscribe/mod.rs b/src/subscribe/mod.rs index 1796fb4..1cb3092 100644 --- a/src/subscribe/mod.rs +++ b/src/subscribe/mod.rs @@ -70,7 +70,10 @@ pub async fn import( pub async fn subscribe(app: &App, name: Option, url: Url) -> Result<()> { if !(url.as_str().ends_with("videos") || url.as_str().ends_with("streams") - || url.as_str().ends_with("shorts")) + || url.as_str().ends_with("shorts") + || url.as_str().ends_with("videos/") + || url.as_str().ends_with("streams/") + || url.as_str().ends_with("shorts/")) && url.as_str().contains("youtube.com") { warn!("Your youtbe url does not seem like it actually tracks a channels playlist (videos, streams, shorts). Adding subscriptions for each of them..."); @@ -135,11 +138,11 @@ pub async fn subscribe(app: &App, name: Option, url: Url) -> Result<()> } async fn actual_subscribe(app: &App, name: Option, url: Url) -> Result<()> { - let name = if let Some(name) = name { - if !check_url(&url).await? { - bail!("The url ('{}') does not represent a playlist!", &url) - }; + if !check_url(&url).await? { + bail!("The url ('{}') does not represent a playlist!", &url) + }; + let name = if let Some(name) = name { name } else { let yt_opts = match json!( { -- cgit 1.4.1