add error message for playlists that do not exist
All checks were successful
tests / fmt (push) Successful in 2m19s
tests / build (push) Successful in 2m49s
tests / clippy (push) Successful in 2m46s
tests / test (push) Successful in 3m21s
tests / pre-commit (push) Successful in 3m36s

This commit is contained in:
2024-06-18 10:56:13 +02:00
parent fa17ed75f6
commit a1884c1596

View File

@@ -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."));
}
}
}