From a1884c15960add3bb96a6d554396cf8d120eee67 Mon Sep 17 00:00:00 2001 From: Johannes Heuel Date: Tue, 18 Jun 2024 10:56:13 +0200 Subject: [PATCH] add error message for playlists that do not exist --- src/commands/play.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/commands/play.rs b/src/commands/play.rs index 9ef9c5e..1384a04 100644 --- a/src/commands/play.rs +++ b/src/commands/play.rs @@ -53,6 +53,9 @@ async fn get_tracks( if stderr.contains("This video is only available to Music Premium members") { return Err("This video is only available to Music Premium members".into()); } + if stderr.contains("YouTube said: The playlist does not exist.") { + return Err("YouTube said: The playlist does not exist.".into()); + } } return Err("No tracks found".into()); } @@ -274,4 +277,19 @@ mod tests { .contains("This video is only available to Music Premium members")); } } + + #[tokio::test] + async fn test_playlist_does_not_exist_tracks() { + let urls = ["https://www.youtube.com/playlist?list=PLox0oG0uy8Lc1IaIfGyrvtuRItuEyJiyG"]; + for url in urls.iter() { + println!("url: {:?}", url); + let tracks = get_tracks(url.to_string()).await; + assert!(tracks.is_err()); + assert!(tracks + .err() + .unwrap() + .to_string() + .contains("YouTube said: The playlist does not exist.")); + } + } }