add error message for playlists that do not exist
Some checks failed
tests / fmt (push) Successful in 2m7s
tests / pre-commit (push) Successful in 2m24s
tests / clippy (push) Successful in 2m25s
tests / test (push) Successful in 2m29s
tests / build (push) Successful in 2m45s
deploy / release-image (push) Has been cancelled

This commit was merged in pull request #7.
This commit is contained in:
2024-06-18 10:56:13 +02:00
committed by Johannes Heuel
parent d6a54dfc06
commit feccbebd4d

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