diff --git a/Cargo.toml b/Cargo.toml index 4fe485e..8803f28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ time = { version = "0.3.15", features = [ futures = "0.3.21" ress = "0.11.4" phf = "0.11.1" -base64 = "0.22.0" +base64 = "0.21.0" urlencoding = "2.1.2" quick-xml = { version = "0.31.0", features = ["serialize"], optional = true } tracing = { version = "0.1.37", features = ["log"] } diff --git a/src/client/mod.rs b/src/client/mod.rs index 5b239c6..e014d18 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -1602,24 +1602,24 @@ mod tests { parts[0].parse().unwrap() } - #[tokio::test] - async fn t_extract_desktop_client_version() { + #[test] + fn t_extract_desktop_client_version() { let rp = RustyPipe::new(); - let version = rp.extract_desktop_client_version().await.unwrap(); + let version = tokio_test::block_on(rp.extract_desktop_client_version()).unwrap(); assert!(get_major_version(&version) >= 2); } - #[tokio::test] - async fn t_extract_music_client_version() { + #[test] + fn t_extract_music_client_version() { let rp = RustyPipe::new(); - let version = rp.extract_music_client_version().await.unwrap(); + let version = tokio_test::block_on(rp.extract_music_client_version()).unwrap(); assert!(get_major_version(&version) >= 1); } - #[tokio::test] - async fn t_get_visitor_data() { + #[test] + fn t_get_visitor_data() { let rp = RustyPipe::new(); - let visitor_data = rp.get_visitor_data().await.unwrap(); + let visitor_data = tokio_test::block_on(rp.get_visitor_data()).unwrap(); assert!( visitor_data.starts_with("Cg") && visitor_data.len() > 23, diff --git a/src/deobfuscate.rs b/src/deobfuscate.rs index 776d221..cf31cca 100644 --- a/src/deobfuscate.rs +++ b/src/deobfuscate.rs @@ -426,18 +426,18 @@ c[36](c[8],c[32]),c[20](c[25],c[10]),c[2](c[22],c[8]),c[32](c[20],c[16]),c[32](c assert_eq!(res, "nrkec0fwgTWolw"); } - #[tokio::test] - async fn t_get_player_js_url() { + #[test] + fn t_get_player_js_url() { let client = Client::new(); - let url = get_player_js_url(&client).await.unwrap(); + let url = tokio_test::block_on(get_player_js_url(&client)).unwrap(); assert!(url.starts_with("https://www.youtube.com/s/player")); assert_eq!(url.len(), 73); } - #[tokio::test] - async fn t_update() { + #[test] + fn t_update() { let client = Client::new(); - let deobf_data = DeobfData::extract(client, None).await.unwrap(); + let deobf_data = tokio_test::block_on(DeobfData::extract(client, None)).unwrap(); let deobf = Deobfuscator::new(&deobf_data).unwrap(); let deobf_sig = deobf.deobfuscate_sig("GOqGOqGOq0QJ8wRAIgaryQHfplJ9xJSKFywyaSMHuuwZYsoMTAvRvfm51qIGECIA5061zWeyfMPX9hEl_U6f9J0tr7GTJMKyPf5XNrJb5fb5i").unwrap(); diff --git a/tests/youtube.rs b/tests/youtube.rs index 1cb2458..9f5d730 100644 --- a/tests/youtube.rs +++ b/tests/youtube.rs @@ -29,13 +29,9 @@ use rustypipe::validate; #[case::tv_html5_embed(ClientType::TvHtml5Embed)] #[case::android(ClientType::Android)] #[case::ios(ClientType::Ios)] -#[tokio::test] -async fn get_player_from_client(#[case] client_type: ClientType, rp: RustyPipe) { - let player_data = rp - .query() - .player_from_client("n4tK7LYFxI0", client_type) - .await - .unwrap(); +fn get_player_from_client(#[case] client_type: ClientType, rp: RustyPipe) { + let player_data = + tokio_test::block_on(rp.query().player_from_client("n4tK7LYFxI0", client_type)).unwrap(); // dbg!(&player_data); @@ -95,8 +91,8 @@ async fn get_player_from_client(#[case] client_type: ClientType, rp: RustyPipe) assert_eq!(audio.format, AudioFormat::M4a); assert_eq!(audio.codec, AudioCodec::Mp4a); - check_video_stream(video).await; - check_video_stream(audio).await; + check_video_stream(video); + check_video_stream(audio); } else { let video = player_data .video_only_streams @@ -130,21 +126,18 @@ async fn get_player_from_client(#[case] client_type: ClientType, rp: RustyPipe) assert_eq!(audio.codec, AudioCodec::Opus); assert!(!audio.throttled); - check_video_stream(video).await; - check_video_stream(audio).await; + check_video_stream(video); + check_video_stream(audio); } assert!(player_data.expires_in_seconds > 10000); } /// Request the given stream to check if it returns a valid response -async fn check_video_stream(s: impl YtStream) { +fn check_video_stream(s: impl YtStream) { let http = reqwest::Client::new(); - let resp = http - .get(s.url()) - .send() - .await + let resp = tokio_test::block_on(http.get(s.url()).send()) .unwrap() .error_for_status() .unwrap(); @@ -221,9 +214,8 @@ async fn check_video_stream(s: impl YtStream) { false, false )] -#[tokio::test] #[allow(clippy::too_many_arguments)] -async fn get_player( +fn get_player( #[case] id: &str, #[case] name: &str, #[case] description: &str, @@ -235,7 +227,7 @@ async fn get_player( #[case] is_live_content: bool, rp: RustyPipe, ) { - let player_data = rp.query().player(id).await.unwrap(); + let player_data = tokio_test::block_on(rp.query().player(id)).unwrap(); let details = player_data.details; assert_eq!(details.id, id); @@ -316,9 +308,8 @@ async fn get_player( #[case::age_restricted("CUO8secmc0g", UnavailabilityReason::AgeRestricted)] #[case::premium_only("3LvozjEOUxU", UnavailabilityReason::Premium)] #[case::members_only("vYmAhoZYg64", UnavailabilityReason::MembersOnly)] -#[tokio::test] -async fn get_player_error(#[case] id: &str, #[case] expect: UnavailabilityReason, rp: RustyPipe) { - let err = rp.query().player(id).await.unwrap_err(); +fn get_player_error(#[case] id: &str, #[case] expect: UnavailabilityReason, rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().player(id)).unwrap_err(); match err { Error::Extraction(ExtractionError::Unavailable { reason, .. }) => { @@ -329,9 +320,8 @@ async fn get_player_error(#[case] id: &str, #[case] expect: UnavailabilityReason } #[rstest] -#[tokio::test] -async fn get_player_error_paid(rp: RustyPipe) { - let err = rp.query().player("N8ee9OLumrs").await.unwrap_err(); +fn get_player_error_paid(rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().player("N8ee9OLumrs")).unwrap_err(); match err { // Sometimes YouTube shows an 'unplayable' error on paid videos Error::Extraction(ExtractionError::Unavailable { reason, .. }) => { @@ -371,8 +361,7 @@ async fn get_player_error_paid(rp: RustyPipe) { None, Some(("UCvqRdlKsE5Q8mf8YXbdIJLw", "LoL Esports")) )] -#[tokio::test] -async fn get_playlist( +fn get_playlist( #[case] id: &str, #[case] name: &str, #[case] is_long: bool, @@ -381,7 +370,7 @@ async fn get_playlist( rp: RustyPipe, unlocalized: bool, ) { - let playlist = rp.query().playlist(id).await.unwrap(); + let playlist = tokio_test::block_on(rp.query().playlist(id)).unwrap(); assert_eq!(playlist.id, id); if unlocalized { @@ -405,44 +394,28 @@ async fn get_playlist( } #[rstest] -#[tokio::test] -async fn playlist_cont(rp: RustyPipe) { - let mut playlist = rp - .query() - .playlist("PLbZIPy20-1pN7mqjckepWF78ndb6ci_qi") - .await - .unwrap(); +fn playlist_cont(rp: RustyPipe) { + let mut playlist = + tokio_test::block_on(rp.query().playlist("PLbZIPy20-1pN7mqjckepWF78ndb6ci_qi")).unwrap(); - playlist - .videos - .extend_pages(rp.query(), usize::MAX) - .await - .unwrap(); + tokio_test::block_on(playlist.videos.extend_pages(rp.query(), usize::MAX)).unwrap(); assert_gte(playlist.videos.items.len(), 101, "video items"); assert_gteo(playlist.videos.count, 101, "video count"); } #[rstest] -#[tokio::test] -async fn playlist_cont2(rp: RustyPipe) { - let mut playlist = rp - .query() - .playlist("PLbZIPy20-1pN7mqjckepWF78ndb6ci_qi") - .await - .unwrap(); +fn playlist_cont2(rp: RustyPipe) { + let mut playlist = + tokio_test::block_on(rp.query().playlist("PLbZIPy20-1pN7mqjckepWF78ndb6ci_qi")).unwrap(); - playlist.videos.extend_limit(rp.query(), 101).await.unwrap(); + tokio_test::block_on(playlist.videos.extend_limit(rp.query(), 101)).unwrap(); assert_gte(playlist.videos.items.len(), 101, "video items"); assert_gteo(playlist.videos.count, 101, "video count"); } #[rstest] -#[tokio::test] -async fn playlist_not_found(rp: RustyPipe) { - let err = rp - .query() - .playlist("PLbZIPy20-1pN7mqjckepWF78ndb6ci_qz") - .await +fn playlist_not_found(rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().playlist("PLbZIPy20-1pN7mqjckepWF78ndb6ci_qz")) .unwrap_err(); assert!( @@ -454,9 +427,8 @@ async fn playlist_not_found(rp: RustyPipe) { //#VIDEO DETAILS #[rstest] -#[tokio::test] -async fn get_video_details(rp: RustyPipe) { - let details = rp.query().video_details("ZeerrnuLi5E").await.unwrap(); +fn get_video_details(rp: RustyPipe) { + let details = tokio_test::block_on(rp.query().video_details("ZeerrnuLi5E")).unwrap(); // dbg!(&details); @@ -483,7 +455,7 @@ async fn get_video_details(rp: RustyPipe) { assert!(!details.is_ccommons); assert!(details.recommended.visitor_data.is_some()); - assert_next(details.recommended, rp.query(), 10, 1, false).await; + assert_next(details.recommended, rp.query(), 10, 1, false); assert_gteo(details.top_comments.count, 700_000, "comments"); assert!(!details.top_comments.is_exhausted()); @@ -491,9 +463,8 @@ async fn get_video_details(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn get_video_details_music(rp: RustyPipe) { - let details = rp.query().video_details("XuM2onMGvTI").await.unwrap(); +fn get_video_details_music(rp: RustyPipe) { + let details = tokio_test::block_on(rp.query().video_details("XuM2onMGvTI")).unwrap(); // dbg!(&details); @@ -517,7 +488,7 @@ async fn get_video_details_music(rp: RustyPipe) { assert!(!details.is_ccommons); assert!(details.recommended.visitor_data.is_some()); - assert_next(details.recommended, rp.query(), 10, 1, false).await; + assert_next(details.recommended, rp.query(), 10, 1, false); // Update(01.11.2022): comments are sometimes enabled /* @@ -529,9 +500,8 @@ async fn get_video_details_music(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn get_video_details_ccommons(rp: RustyPipe) { - let details = rp.query().video_details("0rb9CfOvojk").await.unwrap(); +fn get_video_details_ccommons(rp: RustyPipe) { + let details = tokio_test::block_on(rp.query().video_details("0rb9CfOvojk")).unwrap(); // dbg!(&details); @@ -561,7 +531,7 @@ async fn get_video_details_ccommons(rp: RustyPipe) { assert!(details.is_ccommons); assert!(details.recommended.visitor_data.is_some()); - assert_next(details.recommended, rp.query(), 10, 1, false).await; + assert_next(details.recommended, rp.query(), 10, 1, false); assert_eq!(details.top_comments.count.unwrap(), 0); assert!(details.top_comments.is_exhausted()); @@ -569,9 +539,8 @@ async fn get_video_details_ccommons(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn get_video_details_chapters(rp: RustyPipe) { - let details = rp.query().video_details("nFDBxBUfE74").await.unwrap(); +fn get_video_details_chapters(rp: RustyPipe) { + let details = tokio_test::block_on(rp.query().video_details("nFDBxBUfE74")).unwrap(); // dbg!(&details); @@ -681,7 +650,7 @@ async fn get_video_details_chapters(rp: RustyPipe) { } assert!(details.recommended.visitor_data.is_some()); - assert_next(details.recommended, rp.query(), 10, 1, false).await; + assert_next(details.recommended, rp.query(), 10, 1, false); assert_gteo(details.top_comments.count, 3000, "comments"); assert!(!details.top_comments.is_exhausted()); @@ -689,9 +658,8 @@ async fn get_video_details_chapters(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn get_video_details_live(rp: RustyPipe) { - let details = rp.query().video_details("jfKfPfyJRdk").await.unwrap(); +fn get_video_details_live(rp: RustyPipe) { + let details = tokio_test::block_on(rp.query().video_details("jfKfPfyJRdk")).unwrap(); // dbg!(&details); @@ -721,7 +689,7 @@ async fn get_video_details_live(rp: RustyPipe) { assert!(!details.is_ccommons); assert!(details.recommended.visitor_data.is_some()); - assert_next(details.recommended, rp.query(), 10, 1, false).await; + assert_next(details.recommended, rp.query(), 10, 1, false); // No comments because livestream assert_eq!(details.top_comments.count, Some(0)); @@ -731,9 +699,8 @@ async fn get_video_details_live(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn get_video_details_agegate(rp: RustyPipe) { - let details = rp.query().video_details("laru0QoJUmI").await.unwrap(); +fn get_video_details_agegate(rp: RustyPipe) { + let details = tokio_test::block_on(rp.query().video_details("laru0QoJUmI")).unwrap(); // dbg!(&details); @@ -761,9 +728,8 @@ async fn get_video_details_agegate(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn get_video_details_no_desc(rp: RustyPipe) { - let details = rp.query().video_details("BXpTGEEZpV8").await.unwrap(); +fn get_video_details_no_desc(rp: RustyPipe) { + let details = tokio_test::block_on(rp.query().video_details("BXpTGEEZpV8")).unwrap(); assert_eq!(details.id, "BXpTGEEZpV8"); assert_eq!( @@ -788,9 +754,8 @@ async fn get_video_details_no_desc(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn get_video_details_not_found(rp: RustyPipe) { - let err = rp.query().video_details("abcdefgLi5X").await.unwrap_err(); +fn get_video_details_not_found(rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().video_details("abcdefgLi5X")).unwrap_err(); assert!( matches!(err, Error::Extraction(ExtractionError::NotFound { .. })), @@ -799,14 +764,10 @@ async fn get_video_details_not_found(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn get_video_comments(rp: RustyPipe) { - let details = rp.query().video_details("ZeerrnuLi5E").await.unwrap(); +fn get_video_comments(rp: RustyPipe) { + let details = tokio_test::block_on(rp.query().video_details("ZeerrnuLi5E")).unwrap(); - let top_comments = details - .top_comments - .next(rp.query()) - .await + let top_comments = tokio_test::block_on(details.top_comments.next(rp.query())) .unwrap() .unwrap(); assert_gte(top_comments.items.len(), 10, "comments"); @@ -815,10 +776,7 @@ async fn get_video_comments(rp: RustyPipe) { assert_gteo(top_comments.count, 700_000, "comments"); - let latest_comments = details - .latest_comments - .next(rp.query()) - .await + let latest_comments = tokio_test::block_on(details.latest_comments.next(rp.query())) .unwrap() .unwrap(); assert_gte(latest_comments.items.len(), 10, "next comments"); @@ -829,13 +787,9 @@ async fn get_video_comments(rp: RustyPipe) { //#CHANNEL #[rstest] -#[tokio::test] -async fn channel_videos(rp: RustyPipe) { - let channel = rp - .query() - .channel_videos("UC2DjFE7Xf11URZqWBigcVOQ") - .await - .unwrap(); +fn channel_videos(rp: RustyPipe) { + let channel = + tokio_test::block_on(rp.query().channel_videos("UC2DjFE7Xf11URZqWBigcVOQ")).unwrap(); // dbg!(&channel); assert_channel_eevblog(&channel); @@ -851,17 +805,16 @@ async fn channel_videos(rp: RustyPipe) { assert!(age_days < 60, "latest video older than 60 days"); - assert_next(channel.content, rp.query(), 15, 2, true).await; + assert_next(channel.content, rp.query(), 15, 2, true); } #[rstest] -#[tokio::test] -async fn channel_shorts(rp: RustyPipe) { - let channel = rp - .query() - .channel_videos_tab("UCh8gHdtzO2tXd593_bjErWg", ChannelVideoTab::Shorts) - .await - .unwrap(); +fn channel_shorts(rp: RustyPipe) { + let channel = tokio_test::block_on( + rp.query() + .channel_videos_tab("UCh8gHdtzO2tXd593_bjErWg", ChannelVideoTab::Shorts), + ) + .unwrap(); // dbg!(&channel); assert_eq!(channel.id, "UCh8gHdtzO2tXd593_bjErWg"); @@ -883,17 +836,16 @@ async fn channel_shorts(rp: RustyPipe) { "got no shorts" ); - // assert_next(channel.content, rp.query(), 15, 1, true).await; + // assert_next(channel.content, rp.query(), 15, 1, true); } #[rstest] -#[tokio::test] -async fn channel_livestreams(rp: RustyPipe) { - let channel = rp - .query() - .channel_videos_tab("UC2DjFE7Xf11URZqWBigcVOQ", ChannelVideoTab::Live) - .await - .unwrap(); +fn channel_livestreams(rp: RustyPipe) { + let channel = tokio_test::block_on( + rp.query() + .channel_videos_tab("UC2DjFE7Xf11URZqWBigcVOQ", ChannelVideoTab::Live), + ) + .unwrap(); // dbg!(&channel); assert_channel_eevblog(&channel); @@ -903,17 +855,13 @@ async fn channel_livestreams(rp: RustyPipe) { "got no streams" ); - assert_next(channel.content, rp.query(), 5, 1, true).await; + assert_next(channel.content, rp.query(), 5, 1, true); } #[rstest] -#[tokio::test] -async fn channel_playlists(rp: RustyPipe) { - let channel = rp - .query() - .channel_playlists("UC2DjFE7Xf11URZqWBigcVOQ") - .await - .unwrap(); +fn channel_playlists(rp: RustyPipe) { + let channel = + tokio_test::block_on(rp.query().channel_playlists("UC2DjFE7Xf11URZqWBigcVOQ")).unwrap(); assert_channel_eevblog(&channel); @@ -922,17 +870,12 @@ async fn channel_playlists(rp: RustyPipe) { "got no playlists" ); - assert_next(channel.content, rp.query(), 15, 1, true).await; + assert_next(channel.content, rp.query(), 15, 1, true); } #[rstest] -#[tokio::test] -async fn channel_info(rp: RustyPipe) { - let info = rp - .query() - .channel_info("UC2DjFE7Xf11URZqWBigcVOQ") - .await - .unwrap(); +fn channel_info(rp: RustyPipe) { + let info = tokio_test::block_on(rp.query().channel_info("UC2DjFE7Xf11URZqWBigcVOQ")).unwrap(); assert_eq!(info.create_date, Some(date!(2009 - 4 - 4))); assert_gteo(info.view_count, 186_854_340, "channel views"); @@ -960,16 +903,15 @@ async fn channel_info(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn channel_search(rp: RustyPipe) { - let channel = rp - .query() - .channel_search("UC2DjFE7Xf11URZqWBigcVOQ", "test") - .await - .unwrap(); +fn channel_search(rp: RustyPipe) { + let channel = tokio_test::block_on( + rp.query() + .channel_search("UC2DjFE7Xf11URZqWBigcVOQ", "test"), + ) + .unwrap(); assert_channel_eevblog(&channel); - assert_next(channel.content, rp.query(), 20, 2, true).await; + assert_next(channel.content, rp.query(), 20, 2, true); } fn assert_channel_eevblog(channel: &Channel) { @@ -998,8 +940,7 @@ fn assert_channel_eevblog(channel: &Channel) { true )] #[case::music("UC-9-kyTW8ZkZNDHQJ6FgpwQ", "Music", false, false, false)] -#[tokio::test] -async fn channel_more( +fn channel_more( #[case] id: &str, #[case] name: &str, #[case] has_videos: bool, @@ -1017,13 +958,13 @@ async fn channel_more( } if has_videos { - let channel_videos = rp.query().channel_videos(&id).await.unwrap(); + let channel_videos = tokio_test::block_on(rp.query().channel_videos(&id)).unwrap(); assert_channel(&channel_videos, id, name, unlocalized || name_unlocalized); assert!(!channel_videos.content.items.is_empty(), "got no videos"); } if has_playlists { - let channel_playlists = rp.query().channel_playlists(&id).await.unwrap(); + let channel_playlists = tokio_test::block_on(rp.query().channel_playlists(&id)).unwrap(); assert_channel( &channel_playlists, id, @@ -1036,7 +977,7 @@ async fn channel_more( ); } - let info = rp.query().channel_info(&id).await.unwrap(); + let info = tokio_test::block_on(rp.query().channel_info(&id)).unwrap(); assert_eq!(info.id, id); } @@ -1044,13 +985,13 @@ async fn channel_more( #[case::videos("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Videos)] #[case::live("UCvqRdlKsE5Q8mf8YXbdIJLw", ChannelVideoTab::Live)] #[case::shorts("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Shorts)] -#[tokio::test] -async fn channel_order_latest(#[case] id: &str, #[case] tab: ChannelVideoTab, rp: RustyPipe) { - let latest = rp - .query() - .channel_videos_tab_order(id, tab, ChannelOrder::Latest) - .await - .unwrap(); +fn channel_order_latest(#[case] id: &str, #[case] tab: ChannelVideoTab, rp: RustyPipe) { + let latest = tokio_test::block_on(rp.query().channel_videos_tab_order( + id, + tab, + ChannelOrder::Latest, + )) + .unwrap(); // Upload dates should be in descending order if tab == ChannelVideoTab::Videos { let mut latest_items = latest.items.iter().peekable(); @@ -1066,7 +1007,7 @@ async fn channel_order_latest(#[case] id: &str, #[case] tab: ChannelVideoTab, rp } if tab != ChannelVideoTab::Shorts { - assert_next(latest, rp.query(), 15, 1, true).await; + assert_next(latest, rp.query(), 15, 1, true); } } @@ -1074,18 +1015,18 @@ async fn channel_order_latest(#[case] id: &str, #[case] tab: ChannelVideoTab, rp #[case::videos("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Videos, "XqZsoesa55w")] #[case::live("UCvqRdlKsE5Q8mf8YXbdIJLw", ChannelVideoTab::Live, "ojes5ULOqhc")] #[case::shorts("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Shorts, "k91vRvXGwHs")] -#[tokio::test] -async fn channel_order_popular( +fn channel_order_popular( #[case] id: &str, #[case] tab: ChannelVideoTab, #[case] most_popular: &str, rp: RustyPipe, ) { - let popular = rp - .query() - .channel_videos_tab_order(id, tab, ChannelOrder::Popular) - .await - .unwrap(); + let popular = tokio_test::block_on(rp.query().channel_videos_tab_order( + id, + tab, + ChannelOrder::Popular, + )) + .unwrap(); // Most popular video should be in top 5 assert!( popular.items.iter().take(5).any(|v| v.id == most_popular), @@ -1106,25 +1047,25 @@ async fn channel_order_popular( } if tab != ChannelVideoTab::Shorts { - assert_next(popular, rp.query(), 15, 1, true).await; + assert_next(popular, rp.query(), 15, 1, true); } } #[rstest] #[case::videos("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Videos, "P2gDffkC0rY")] #[case::live("UCvqRdlKsE5Q8mf8YXbdIJLw", ChannelVideoTab::Live, "aW43RH1kQ70")] -#[tokio::test] -async fn channel_order_oldest( +fn channel_order_oldest( #[case] id: &str, #[case] tab: ChannelVideoTab, #[case] oldest: &str, rp: RustyPipe, ) { - let videos = rp - .query() - .channel_videos_tab_order(id, tab, ChannelOrder::Oldest) - .await - .unwrap(); + let videos = tokio_test::block_on(rp.query().channel_videos_tab_order( + id, + tab, + ChannelOrder::Oldest, + )) + .unwrap(); // Check oldest video assert_eq!(videos.items.first().expect("no videos").id, oldest); @@ -1140,7 +1081,7 @@ async fn channel_order_oldest( ); } } - assert_next(videos, rp.query(), 15, 1, true).await; + assert_next(videos, rp.query(), 15, 1, true); } #[rstest] @@ -1151,9 +1092,8 @@ async fn channel_order_oldest( #[case::learning("UCtFRv9O2AHqOZjjynzrv-xg")] #[case::live("UC4R8DWoMoI7CAwX8_LjQHig")] // #[case::news("UCYfdidRxbB8Qhf0Nx7ioOYw")] -#[tokio::test] -async fn channel_not_found(#[case] id: &str, rp: RustyPipe) { - let err = rp.query().channel_videos(&id).await.unwrap_err(); +fn channel_not_found(#[case] id: &str, rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().channel_videos(&id)).unwrap_err(); assert!( matches!(err, Error::Extraction(ExtractionError::NotFound { .. })), @@ -1164,23 +1104,21 @@ async fn channel_not_found(#[case] id: &str, rp: RustyPipe) { #[rstest] #[case::shorts(ChannelVideoTab::Shorts)] #[case::live(ChannelVideoTab::Live)] -#[tokio::test] -async fn channel_tab_not_found(#[case] tab: ChannelVideoTab, rp: RustyPipe) { - let channel = rp - .query() - .channel_videos_tab("UCGiJh0NZ52wRhYKYnuZI08Q", tab) - .await - .unwrap(); +fn channel_tab_not_found(#[case] tab: ChannelVideoTab, rp: RustyPipe) { + let channel = tokio_test::block_on( + rp.query() + .channel_videos_tab("UCGiJh0NZ52wRhYKYnuZI08Q", tab), + ) + .unwrap(); assert!(channel.content.is_empty(), "got: {:?}", channel.content); } #[rstest] -#[tokio::test] -async fn channel_age_restriction(rp: RustyPipe) { +fn channel_age_restriction(rp: RustyPipe) { let id = "UCbfnHqxXs_K3kvaH-WlNlig"; - let res = rp.query().channel_videos(&id).await; + let res = tokio_test::block_on(rp.query().channel_videos(&id)); if let Err(Error::Extraction(ExtractionError::Unavailable { reason, msg })) = res { assert_eq!(reason, UnavailabilityReason::AgeRestricted); assert!(msg.starts_with("Laphroaig Whisky: ")); @@ -1188,7 +1126,7 @@ async fn channel_age_restriction(rp: RustyPipe) { panic!("invalid res: {res:?}") } - let res = rp.query().channel_info(&id).await; + let res = tokio_test::block_on(rp.query().channel_info(&id)); if let Err(Error::Extraction(ExtractionError::Unavailable { reason, msg })) = res { assert_eq!(reason, UnavailabilityReason::AgeRestricted); assert!(msg.starts_with("Laphroaig Whisky: ")); @@ -1205,13 +1143,9 @@ mod channel_rss { use time::macros::datetime; #[rstest] - #[tokio::test] - async fn get_channel_rss(rp: RustyPipe) { - let channel = rp - .query() - .channel_rss("UCHnyfMqiRRG1u-2MsSQLbXA") - .await - .unwrap(); + fn get_channel_rss(rp: RustyPipe) { + let channel = + tokio_test::block_on(rp.query().channel_rss("UCHnyfMqiRRG1u-2MsSQLbXA")).unwrap(); assert_eq!(channel.id, "UCHnyfMqiRRG1u-2MsSQLbXA"); assert_eq!(channel.name, "Veritasium"); @@ -1221,13 +1155,9 @@ mod channel_rss { } #[rstest] - #[tokio::test] - async fn get_channel_rss_empty(rp: RustyPipe) { - let channel = rp - .query() - .channel_rss("UCAyFbMjB3qAQSZBj6NCuBSg") - .await - .unwrap(); + fn get_channel_rss_empty(rp: RustyPipe) { + let channel = + tokio_test::block_on(rp.query().channel_rss("UCAyFbMjB3qAQSZBj6NCuBSg")).unwrap(); assert_eq!(channel.id, "UCAyFbMjB3qAQSZBj6NCuBSg"); assert_eq!(channel.name, "Cheryl Calogero"); @@ -1236,13 +1166,9 @@ mod channel_rss { } #[rstest] - #[tokio::test] - async fn get_channel_rss_not_found(rp: RustyPipe) { - let err = rp - .query() - .channel_rss("UCHnyfMqiRRG1u-2MsSQLbXZ") - .await - .unwrap_err(); + fn get_channel_rss_not_found(rp: RustyPipe) { + let err = + tokio_test::block_on(rp.query().channel_rss("UCHnyfMqiRRG1u-2MsSQLbXZ")).unwrap_err(); assert!( matches!(err, Error::Extraction(ExtractionError::NotFound { .. })), @@ -1255,13 +1181,8 @@ mod channel_rss { //#SEARCH #[rstest] -#[tokio::test] -async fn search(rp: RustyPipe, unlocalized: bool) { - let result = rp - .query() - .search::("doobydoobap") - .await - .unwrap(); +fn search(rp: RustyPipe, unlocalized: bool) { + let result = tokio_test::block_on(rp.query().search::("doobydoobap")).unwrap(); assert_gteo( result.items.count, @@ -1273,25 +1194,21 @@ async fn search(rp: RustyPipe, unlocalized: bool) { assert_eq!(result.corrected_query.as_deref(), Some("doobydobap")); } - assert_next(result.items, rp.query(), 10, 2, true).await; + assert_next(result.items, rp.query(), 10, 2, true); } #[rstest] #[case::video(search_filter::ItemType::Video)] #[case::channel(search_filter::ItemType::Channel)] #[case::playlist(search_filter::ItemType::Playlist)] -#[tokio::test] -async fn search_filter_item_type(#[case] item_type: search_filter::ItemType, rp: RustyPipe) { - let mut result = rp - .query() - .search_filter::( - "with no videos", - &SearchFilter::new().item_type(item_type), - ) - .await - .unwrap(); +fn search_filter_item_type(#[case] item_type: search_filter::ItemType, rp: RustyPipe) { + let mut result = tokio_test::block_on(rp.query().search_filter::( + "with no videos", + &SearchFilter::new().item_type(item_type), + )) + .unwrap(); - result.items.extend(rp.query()).await.unwrap(); + tokio_test::block_on(result.items.extend(rp.query())).unwrap(); assert_gte(result.items.items.len(), 20, "items"); result.items.items.iter().for_each(|item| match item { @@ -1308,18 +1225,16 @@ async fn search_filter_item_type(#[case] item_type: search_filter::ItemType, rp: } #[rstest] -#[tokio::test] -async fn search_empty(rp: RustyPipe) { - let result = rp - .query() - .search_filter::( +fn search_empty(rp: RustyPipe) { + let result = tokio_test::block_on( + rp.query().search_filter::( "3gig84hgi34gu8vj34gj489", &search_filter::SearchFilter::new() .feature(search_filter::Feature::IsLive) .feature(search_filter::Feature::Is3d), - ) - .await - .unwrap(); + ), + ) + .unwrap(); assert!(result.items.is_empty()); } @@ -1327,38 +1242,33 @@ async fn search_empty(rp: RustyPipe) { #[rstest] #[case::no_filter(false)] #[case::filter(true)] -#[tokio::test] -async fn search_sensitive(rp: RustyPipe, #[case] filter: bool) { +fn search_sensitive(rp: RustyPipe, #[case] filter: bool) { let q = "suicide"; let result = if filter { - rp.query() - .search_filter::(q, &search_filter::SearchFilter::new()) - .await + tokio_test::block_on( + rp.query() + .search_filter::(q, &search_filter::SearchFilter::new()), + ) } else { - rp.query().search::(q).await + tokio_test::block_on(rp.query().search::(q)) } .unwrap(); assert_gteo(result.items.count, 10_000, "results"); - assert_next(result.items, rp.query(), 10, 2, true).await; + assert_next(result.items, rp.query(), 10, 2, true); } #[rstest] -#[tokio::test] -async fn search_suggestion(rp: RustyPipe) { - let result = rp.query().search_suggestion("hunger ga").await.unwrap(); +fn search_suggestion(rp: RustyPipe) { + let result = tokio_test::block_on(rp.query().search_suggestion("hunger ga")).unwrap(); assert!(result.iter().any(|s| s.starts_with("hunger games"))); assert_gte(result.len(), 10, "search suggestions"); } #[rstest] -#[tokio::test] -async fn search_suggestion_empty(rp: RustyPipe) { - let result = rp - .query() - .search_suggestion("fjew327p4ifjelwfvnewg49") - .await - .unwrap(); +fn search_suggestion_empty(rp: RustyPipe) { + let result = + tokio_test::block_on(rp.query().search_suggestion("fjew327p4ifjelwfvnewg49")).unwrap(); assert!(result.is_empty()); } @@ -1388,9 +1298,8 @@ async fn search_suggestion_empty(rp: RustyPipe) { #[case("https://music.youtube.com/browse/MPREb_GyH43gCvdM5", UrlTarget::Album {id: "MPREb_GyH43gCvdM5".to_owned()})] #[case("https://music.youtube.com/browse/UC5I2hjZYiW9gZPVkvzM8_Cw", UrlTarget::Channel {id: "UC5I2hjZYiW9gZPVkvzM8_Cw".to_owned()})] #[case("https://music.youtube.com/browse/MPADUC7cl4MmM6ZZ2TcFyMk_b4pg", UrlTarget::Channel {id: "UC7cl4MmM6ZZ2TcFyMk_b4pg".to_owned()})] -#[tokio::test] -async fn resolve_url(#[case] url: &str, #[case] expect: UrlTarget, rp: RustyPipe) { - let target = rp.query().resolve_url(url, true).await.unwrap(); +fn resolve_url(#[case] url: &str, #[case] expect: UrlTarget, rp: RustyPipe) { + let target = tokio_test::block_on(rp.query().resolve_url(url, true)).unwrap(); assert_eq!(target, expect); } @@ -1407,20 +1316,18 @@ async fn resolve_url(#[case] url: &str, #[case] expect: UrlTarget, rp: RustyPipe #[case("OLAK5uy_k0yFrZlFRgCf3rLPza-lkRmCrtLPbK9pE", UrlTarget::Album {id: "MPREb_GyH43gCvdM5".to_owned()})] #[case("MPREb_GyH43gCvdM5", UrlTarget::Album {id: "MPREb_GyH43gCvdM5".to_owned()})] #[case("MPADUC7cl4MmM6ZZ2TcFyMk_b4pg", UrlTarget::Channel {id: "UC7cl4MmM6ZZ2TcFyMk_b4pg".to_owned()})] -#[tokio::test] -async fn resolve_string(#[case] string: &str, #[case] expect: UrlTarget, rp: RustyPipe) { - let target = rp.query().resolve_string(string, true).await.unwrap(); +fn resolve_string(#[case] string: &str, #[case] expect: UrlTarget, rp: RustyPipe) { + let target = tokio_test::block_on(rp.query().resolve_string(string, true)).unwrap(); assert_eq!(target, expect); } #[rstest] -#[tokio::test] -async fn resolve_channel_not_found(rp: RustyPipe) { - let err = rp - .query() - .resolve_url("https://www.youtube.com/feeqegnhq3rkwghjq43ruih43io3", true) - .await - .unwrap_err(); +fn resolve_channel_not_found(rp: RustyPipe) { + let err = tokio_test::block_on( + rp.query() + .resolve_url("https://www.youtube.com/feeqegnhq3rkwghjq43ruih43io3", true), + ) + .unwrap_err(); assert!(matches!( err, @@ -1431,21 +1338,19 @@ async fn resolve_channel_not_found(rp: RustyPipe) { //#TRENDS #[rstest] -#[tokio::test] #[ignore] -async fn startpage(rp: RustyPipe) { - let startpage = rp.query().startpage().await.unwrap(); +fn startpage(rp: RustyPipe) { + let startpage = tokio_test::block_on(rp.query().startpage()).unwrap(); // The startpage requires visitor data to fetch continuations assert!(startpage.visitor_data.is_some()); - assert_next(startpage, rp.query(), 8, 2, true).await; + assert_next(startpage, rp.query(), 8, 2, true); } #[rstest] -#[tokio::test] -async fn trending(rp: RustyPipe) { - let result = rp.query().trending().await.unwrap(); +fn trending(rp: RustyPipe) { + let result = tokio_test::block_on(rp.query().trending()).unwrap(); assert_gte(result.len(), 40, "items"); } @@ -1477,8 +1382,7 @@ async fn trending(rp: RustyPipe) { Some(("UCQM0bS4_04-Y4JuYrgmnpZQ", "Chaosflo44")), false, )] -#[tokio::test] -async fn music_playlist( +fn music_playlist( #[case] id: &str, #[case] name: &str, #[case] is_long: bool, @@ -1488,7 +1392,7 @@ async fn music_playlist( rp: RustyPipe, unlocalized: bool, ) { - let playlist = rp.query().music_playlist(id).await.unwrap(); + let playlist = tokio_test::block_on(rp.query().music_playlist(id)).unwrap(); assert_eq!(playlist.id, id); assert!(!playlist.tracks.is_empty()); @@ -1515,11 +1419,10 @@ async fn music_playlist( #[rstest] #[case::user("PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj")] #[case::ytm("RDCLAK5uy_kb7EBi6y3GrtJri4_ZH56Ms786DFEimbM")] -#[tokio::test] -async fn music_playlist_cont(#[case] id: &str, rp: RustyPipe) { - let mut playlist = rp.query().music_playlist(id).await.unwrap(); +fn music_playlist_cont(#[case] id: &str, rp: RustyPipe) { + let mut playlist = tokio_test::block_on(rp.query().music_playlist(id)).unwrap(); - playlist.tracks.extend_pages(rp.query(), 5).await.unwrap(); + tokio_test::block_on(playlist.tracks.extend_pages(rp.query(), 5)).unwrap(); let track_count = playlist.track_count.unwrap(); assert_gte(track_count, 100, "tracks"); @@ -1533,15 +1436,14 @@ async fn music_playlist_cont(#[case] id: &str, rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_playlist_related(rp: RustyPipe) { - let mut playlist = rp - .query() - .music_playlist("PLbZIPy20-1pN7mqjckepWF78ndb6ci_qi") - .await - .unwrap(); +fn music_playlist_related(rp: RustyPipe) { + let mut playlist = tokio_test::block_on( + rp.query() + .music_playlist("PLbZIPy20-1pN7mqjckepWF78ndb6ci_qi"), + ) + .unwrap(); - playlist.related_playlists.extend(rp.query()).await.unwrap(); + tokio_test::block_on(playlist.related_playlists.extend(rp.query())).unwrap(); assert_gte( playlist.related_playlists.items.len(), @@ -1551,13 +1453,12 @@ async fn music_playlist_related(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_playlist_not_found(rp: RustyPipe) { - let err = rp - .query() - .music_playlist("PLbZIPy20-1pN7mqjckepWF78ndb6ci_qz") - .await - .unwrap_err(); +fn music_playlist_not_found(rp: RustyPipe) { + let err = tokio_test::block_on( + rp.query() + .music_playlist("PLbZIPy20-1pN7mqjckepWF78ndb6ci_qz"), + ) + .unwrap_err(); assert!( matches!(err, Error::Extraction(ExtractionError::NotFound { .. })), @@ -1576,18 +1477,17 @@ async fn music_playlist_not_found(rp: RustyPipe) { #[case::no_year("no_year", "MPREb_F3Af9UZZVxX")] #[case::version_no_artist("version_no_artist", "MPREb_h8ltx5oKvyY")] #[case::no_artist("no_artist", "MPREb_bqWA6mAZFWS")] -#[tokio::test] -async fn music_album(#[case] name: &str, #[case] id: &str, rp: RustyPipe, unlocalized: bool) { +fn music_album(#[case] name: &str, #[case] id: &str, rp: RustyPipe, unlocalized: bool) { // TODO: remove visitor data if A/B#13 is stabilized - let album = rp - .query() - .visitor_data_opt( - Some("Cgs1bHFWMlhmM1ZFNCi9jK6vBjIKCgJERRIEEgAgIw%3D%3D") - .filter(|_| name == "one_artist"), - ) - .music_album(id) - .await - .unwrap(); + let album = tokio_test::block_on( + rp.query() + .visitor_data_opt( + Some("Cgs1bHFWMlhmM1ZFNCi9jK6vBjIKCgJERRIEEgAgIw%3D%3D") + .filter(|_| name == "one_artist"), + ) + .music_album(id), + ) + .unwrap(); assert!(!album.cover.is_empty(), "got no cover"); @@ -1613,13 +1513,8 @@ async fn music_album(#[case] name: &str, #[case] id: &str, rp: RustyPipe, unloca } #[rstest] -#[tokio::test] -async fn music_album_not_found(rp: RustyPipe) { - let err = rp - .query() - .music_album("MPREb_nlBWQROfvjoz") - .await - .unwrap_err(); +fn music_album_not_found(rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().music_album("MPREb_nlBWQROfvjoz")).unwrap_err(); assert!( matches!(err, Error::Extraction(ExtractionError::NotFound { .. })), @@ -1636,8 +1531,7 @@ async fn music_album_not_found(rp: RustyPipe) { #[case::no_artist("no_artist", "UCh8gHdtzO2tXd593_bjErWg", false, 0, 0)] // querying Trailerpark's secondary YouTube channel should result in the YTM channel being fetched #[case::secondary_channel("no_more_albums", "UCC9192yGQD25eBZgFZ84MPw", true, 15, 0)] -#[tokio::test] -async fn music_artist( +fn music_artist( #[case] name: &str, #[case] id: &str, #[case] all_albums: bool, @@ -1646,7 +1540,7 @@ async fn music_artist( rp: RustyPipe, unlocalized: bool, ) { - let mut artist = rp.query().music_artist(id, all_albums).await.unwrap(); + let mut artist = tokio_test::block_on(rp.query().music_artist(id, all_albums)).unwrap(); assert_gte(artist.tracks.len(), min_tracks, "tracks"); assert_gte(artist.playlists.len(), min_playlists, "playlists"); @@ -1712,7 +1606,7 @@ async fn music_artist( // Fetch albums seperately if name != "no_artist" { - let albums = rp.query().music_artist_albums(id).await.unwrap(); + let albums = tokio_test::block_on(rp.query().music_artist_albums(id)).unwrap(); let albums_expect = artist .albums .iter() @@ -1732,12 +1626,8 @@ async fn music_artist( } #[rstest] -#[tokio::test] -async fn music_artist_not_found(rp: RustyPipe) { - let err = rp - .query() - .music_artist("UC7cl4MmM6ZZ2TcFyMk_b4pq", false) - .await +fn music_artist_not_found(rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().music_artist("UC7cl4MmM6ZZ2TcFyMk_b4pq", false)) .unwrap_err(); assert!( @@ -1747,12 +1637,8 @@ async fn music_artist_not_found(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_artist_albums_not_found(rp: RustyPipe) { - let err = rp - .query() - .music_artist_albums("UC7cl4MmM6ZZ2TcFyMk_b4pq") - .await +fn music_artist_albums_not_found(rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().music_artist_albums("UC7cl4MmM6ZZ2TcFyMk_b4pq")) .unwrap_err(); assert!( @@ -1764,16 +1650,12 @@ async fn music_artist_albums_not_found(rp: RustyPipe) { #[rstest] #[case::default(false)] #[case::typo(true)] -#[tokio::test] -async fn music_search_main(#[case] typo: bool, rp: RustyPipe, unlocalized: bool) { - let res = rp - .query() - .music_search_main(match typo { - false => "lieblingsmensch namika", - true => "lieblingsmesch namika", - }) - .await - .unwrap(); +fn music_search_main(#[case] typo: bool, rp: RustyPipe, unlocalized: bool) { + let res = tokio_test::block_on(rp.query().music_search_main(match typo { + false => "lieblingsmensch namika", + true => "lieblingsmesch namika", + })) + .unwrap(); let items = res.items.items; check_search_result(&items); @@ -1826,9 +1708,8 @@ async fn music_search_main(#[case] typo: bool, rp: RustyPipe, unlocalized: bool) } #[rstest] -#[tokio::test] -async fn music_search_main2(rp: RustyPipe, unlocalized: bool) { - let res = rp.query().music_search_main("taylor swift").await.unwrap(); +fn music_search_main2(rp: RustyPipe, unlocalized: bool) { + let res = tokio_test::block_on(rp.query().music_search_main("taylor swift")).unwrap(); let items = res.items.items; check_search_result(&items); @@ -1888,9 +1769,8 @@ fn check_search_result(items: &[MusicItem]) { } #[rstest] -#[tokio::test] -async fn music_search_tracks(rp: RustyPipe, unlocalized: bool) { - let res = rp.query().music_search_tracks("black mamba").await.unwrap(); +fn music_search_tracks(rp: RustyPipe, unlocalized: bool) { + let res = tokio_test::block_on(rp.query().music_search_tracks("black mamba")).unwrap(); let track = &res .items @@ -1919,13 +1799,12 @@ async fn music_search_tracks(rp: RustyPipe, unlocalized: bool) { assert_eq!(album.id, "MPREb_OpHWHwyNOuY"); assert_eq!(album.name, "Black Mamba"); - assert_next(res.items, rp.query(), 15, 2, true).await; + assert_next(res.items, rp.query(), 15, 2, true); } #[rstest] -#[tokio::test] -async fn music_search_videos(rp: RustyPipe, unlocalized: bool) { - let res = rp.query().music_search_videos("black mamba").await.unwrap(); +fn music_search_videos(rp: RustyPipe, unlocalized: bool) { + let res = tokio_test::block_on(rp.query().music_search_videos("black mamba")).unwrap(); let track = &res .items @@ -1952,31 +1831,24 @@ async fn music_search_videos(rp: RustyPipe, unlocalized: bool) { assert_eq!(track.album, None); assert_gteo(track.view_count, 230_000_000, "views"); - assert_next(res.items, rp.query(), 15, 2, true).await; + assert_next(res.items, rp.query(), 15, 2, true); } #[rstest] #[case::main(false)] #[case::videos(true)] -#[tokio::test] -async fn music_search_episode(rp: RustyPipe, #[case] videos: bool) { +fn music_search_episode(rp: RustyPipe, #[case] videos: bool) { let query = "Blond - Da muss man dabei gewesen sein: Das Hörspiel - Fall #1"; let track_id = "Zq_-LDy7AgE"; let track = if videos { - let items = rp - .query() - .music_search_videos(query) - .await + let items = tokio_test::block_on(rp.query().music_search_videos(query)) .unwrap() .items .items; items.iter().find(|a| a.id == track_id).cloned() } else { - let items = rp - .query() - .music_search_main(query) - .await + let items = tokio_test::block_on(rp.query().music_search_main(query)) .unwrap() .items .items; @@ -2041,8 +1913,7 @@ async fn music_search_episode(rp: RustyPipe, #[case] videos: bool) { AlbumType::Album, true )] -#[tokio::test] -async fn music_search_albums( +fn music_search_albums( #[case] query: &str, #[case] name: &str, #[case] id: &str, @@ -2054,7 +1925,7 @@ async fn music_search_albums( rp: RustyPipe, unlocalized: bool, ) { - let res = rp.query().music_search_albums(query).await.unwrap(); + let res = tokio_test::block_on(rp.query().music_search_albums(query)).unwrap(); let album = &res .items @@ -2081,14 +1952,13 @@ async fn music_search_albums( assert_eq!(res.corrected_query, None); if more && unlocalized { - assert_next(res.items, rp.query(), 15, 1, true).await; + assert_next(res.items, rp.query(), 15, 1, true); } } #[rstest] -#[tokio::test] -async fn music_search_artists(rp: RustyPipe, unlocalized: bool) { - let res = rp.query().music_search_artists("namika").await.unwrap(); +fn music_search_artists(rp: RustyPipe, unlocalized: bool) { + let res = tokio_test::block_on(rp.query().music_search_artists("namika")).unwrap(); let artist = res .items @@ -2107,22 +1977,20 @@ async fn music_search_artists(rp: RustyPipe, unlocalized: bool) { } #[rstest] -#[tokio::test] -async fn music_search_artists_cont(rp: RustyPipe) { - let res = rp.query().music_search_artists("band").await.unwrap(); +fn music_search_artists_cont(rp: RustyPipe) { + let res = tokio_test::block_on(rp.query().music_search_artists("band")).unwrap(); assert_eq!(res.corrected_query, None); - assert_next(res.items, rp.query(), 15, 2, true).await; + assert_next(res.items, rp.query(), 15, 2, true); } #[rstest] -#[tokio::test] -async fn music_search_playlists(rp: RustyPipe, unlocalized: bool) { - let res = rp - .query() - .music_search_playlists("Massive Rock Hits", false) - .await - .unwrap(); +fn music_search_playlists(rp: RustyPipe, unlocalized: bool) { + let res = tokio_test::block_on( + rp.query() + .music_search_playlists("Massive Rock Hits", false), + ) + .unwrap(); assert_eq!(res.corrected_query, None); let playlist = res @@ -2149,13 +2017,12 @@ async fn music_search_playlists(rp: RustyPipe, unlocalized: bool) { } #[rstest] -#[tokio::test] -async fn music_search_playlists_community(rp: RustyPipe) { - let res = rp - .query() - .music_search_playlists("Best Pop Music Videos - Top Pop Hits Playlist", true) - .await - .unwrap(); +fn music_search_playlists_community(rp: RustyPipe) { + let res = tokio_test::block_on( + rp.query() + .music_search_playlists("Best Pop Music Videos - Top Pop Hits Playlist", true), + ) + .unwrap(); assert_eq!(res.corrected_query, None); let playlist = res @@ -2186,22 +2053,20 @@ async fn music_search_playlists_community(rp: RustyPipe) { /// The YouTube Music search sometimes shows genre radio items. They should be skipped. #[rstest] -#[tokio::test] -async fn music_search_genre_radio(rp: RustyPipe) { - rp.query().music_search_main("pop radio").await.unwrap(); +fn music_search_genre_radio(rp: RustyPipe) { + tokio_test::block_on(rp.query().music_search_main("pop radio")).unwrap(); } #[rstest] #[case::default("ed sheer", Some("ed sheeran"), Some("UClmXPfaYhXOYsNn_QUyheWQ"))] #[case::empty("reujbhevmfndxnjrze", None, None)] -#[tokio::test] -async fn music_search_suggestion( +fn music_search_suggestion( #[case] query: &str, #[case] term: Option<&str>, #[case] artist: Option<&str>, rp: RustyPipe, ) { - let suggestion = rp.query().music_search_suggestion(query).await.unwrap(); + let suggestion = tokio_test::block_on(rp.query().music_search_suggestion(query)).unwrap(); match term { Some(expect) => assert!( @@ -2225,9 +2090,8 @@ async fn music_search_suggestion( #[rstest] #[case::mv("mv", "ZeerrnuLi5E")] #[case::track("track", "qIZ-vvg-wiU")] -#[tokio::test] -async fn music_details(#[case] name: &str, #[case] id: &str, rp: RustyPipe) { - let track = rp.query().music_details(id).await.unwrap(); +fn music_details(#[case] name: &str, #[case] id: &str, rp: RustyPipe) { + let track = tokio_test::block_on(rp.query().music_details(id)).unwrap(); assert!(!track.track.cover.is_empty(), "got no cover"); if name == "mv" { @@ -2245,14 +2109,9 @@ async fn music_details(#[case] name: &str, #[case] id: &str, rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_lyrics(rp: RustyPipe) { - let track = rp.query().music_details("60ImQ8DS3Vs").await.unwrap(); - let lyrics = rp - .query() - .music_lyrics(&track.lyrics_id.unwrap()) - .await - .unwrap(); +fn music_lyrics(rp: RustyPipe) { + let track = tokio_test::block_on(rp.query().music_details("60ImQ8DS3Vs")).unwrap(); + let lyrics = tokio_test::block_on(rp.query().music_lyrics(&track.lyrics_id.unwrap())).unwrap(); insta::assert_ron_snapshot!(lyrics.body); assert!( lyrics.footer.contains("Musixmatch"), @@ -2262,14 +2121,9 @@ async fn music_lyrics(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_lyrics_not_found(rp: RustyPipe) { - let track = rp.query().music_details("ekXI8qrbe1s").await.unwrap(); - let err = rp - .query() - .music_lyrics(&track.lyrics_id.unwrap()) - .await - .unwrap_err(); +fn music_lyrics_not_found(rp: RustyPipe) { + let track = tokio_test::block_on(rp.query().music_details("ekXI8qrbe1s")).unwrap(); + let err = tokio_test::block_on(rp.query().music_lyrics(&track.lyrics_id.unwrap())).unwrap_err(); assert!( matches!(err, Error::Extraction(ExtractionError::NotFound { .. })), @@ -2280,14 +2134,10 @@ async fn music_lyrics_not_found(rp: RustyPipe) { #[rstest] #[case::a("7nigXQS1Xb0", true)] #[case::b("4t3SUDZCBaQ", false)] -#[tokio::test] -async fn music_related(#[case] id: &str, #[case] full: bool, rp: RustyPipe) { - let track = rp.query().music_details(id).await.unwrap(); - let related = rp - .query() - .music_related(&track.related_id.unwrap()) - .await - .unwrap(); +fn music_related(#[case] id: &str, #[case] full: bool, rp: RustyPipe) { + let track = tokio_test::block_on(rp.query().music_details(id)).unwrap(); + let related = + tokio_test::block_on(rp.query().music_related(&track.related_id.unwrap())).unwrap(); let n_tracks = related.tracks.len(); let mut track_artists = 0; @@ -2380,9 +2230,8 @@ async fn music_related(#[case] id: &str, #[case] full: bool, rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_details_not_found(rp: RustyPipe) { - let err = rp.query().music_details("7nigXQS1XbZ").await.unwrap_err(); +fn music_details_not_found(rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().music_details("7nigXQS1XbZ")).unwrap_err(); assert!( matches!(err, Error::Extraction(ExtractionError::NotFound { .. })), @@ -2391,20 +2240,14 @@ async fn music_details_not_found(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_radio_track(rp: RustyPipe) { - let tracks = rp.query().music_radio_track("ZeerrnuLi5E").await.unwrap(); - assert_next_items(tracks, rp.query(), 20).await; +fn music_radio_track(rp: RustyPipe) { + let tracks = tokio_test::block_on(rp.query().music_radio_track("ZeerrnuLi5E")).unwrap(); + assert_next_items(tracks, rp.query(), 20); } #[rstest] -#[tokio::test] -async fn music_radio_track_not_found(rp: RustyPipe) { - let err = rp - .query() - .music_radio_track("7nigXQS1XbZ") - .await - .unwrap_err(); +fn music_radio_track_not_found(rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().music_radio_track("7nigXQS1XbZ")).unwrap_err(); assert!( matches!(err, Error::Extraction(ExtractionError::NotFound { .. })), @@ -2413,23 +2256,21 @@ async fn music_radio_track_not_found(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_radio_playlist(rp: RustyPipe) { - let tracks = rp - .query() - .music_radio_playlist("PL5dDx681T4bR7ZF1IuWzOv1omlRbE7PiJ") - .await - .unwrap(); - assert_next_items(tracks, rp.query(), 20).await; +fn music_radio_playlist(rp: RustyPipe) { + let tracks = tokio_test::block_on( + rp.query() + .music_radio_playlist("PL5dDx681T4bR7ZF1IuWzOv1omlRbE7PiJ"), + ) + .unwrap(); + assert_next_items(tracks, rp.query(), 20); } #[rstest] -#[tokio::test] -async fn music_radio_playlist_not_found(rp: RustyPipe) { - let res = rp - .query() - .music_radio_playlist("PL5dDx681T4bR7ZF1IuWzOv1omlZZZZZZZ") - .await; +fn music_radio_playlist_not_found(rp: RustyPipe) { + let res = tokio_test::block_on( + rp.query() + .music_radio_playlist("PL5dDx681T4bR7ZF1IuWzOv1omlZZZZZZZ"), + ); if let Err(err) = res { assert!( @@ -2440,20 +2281,15 @@ async fn music_radio_playlist_not_found(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_radio_artist(rp: RustyPipe) { - let tracks = rp - .query() - .music_radio("RDEM_Ktu-TilkxtLvmc9wX1MLQ") - .await - .unwrap(); - assert_next_items(tracks, rp.query(), 20).await; +fn music_radio_artist(rp: RustyPipe) { + let tracks = + tokio_test::block_on(rp.query().music_radio("RDEM_Ktu-TilkxtLvmc9wX1MLQ")).unwrap(); + assert_next_items(tracks, rp.query(), 20); } #[rstest] -#[tokio::test] -async fn music_radio_not_found(rp: RustyPipe) { - let err = rp.query().music_radio("RDEM_foo").await.unwrap_err(); +fn music_radio_not_found(rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().music_radio("RDEM_foo")).unwrap_err(); assert!( matches!(err, Error::Extraction(ExtractionError::NotFound { .. })), @@ -2472,14 +2308,13 @@ async fn music_radio_not_found(rp: RustyPipe) { "PL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc", "PLrEnWoR732-DtKgaDdnPkezM_nDidBU9H" )] -#[tokio::test] -async fn music_charts( +fn music_charts( #[case] country: Country, #[case] plid_top: &str, #[case] plid_trend: &str, rp: RustyPipe, ) { - let charts = rp.query().music_charts(Some(country)).await.unwrap(); + let charts = tokio_test::block_on(rp.query().music_charts(Some(country))).unwrap(); assert_eq!(charts.top_playlist_id.expect("top_playlist_id"), plid_top); @@ -2502,9 +2337,8 @@ async fn music_charts( } #[rstest] -#[tokio::test] -async fn music_new_albums(rp: RustyPipe) { - let albums = rp.query().music_new_albums().await.unwrap(); +fn music_new_albums(rp: RustyPipe) { + let albums = tokio_test::block_on(rp.query().music_new_albums()).unwrap(); assert_gte(albums.len(), 10, "albums"); for album in albums { @@ -2515,9 +2349,8 @@ async fn music_new_albums(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_new_videos(rp: RustyPipe) { - let videos = rp.query().music_new_videos().await.unwrap(); +fn music_new_videos(rp: RustyPipe) { + let videos = tokio_test::block_on(rp.query().music_new_videos()).unwrap(); assert_gte(videos.len(), 5, "videos"); for video in videos { @@ -2535,9 +2368,8 @@ async fn music_new_videos(rp: RustyPipe) { } #[rstest] -#[tokio::test] -async fn music_genres(rp: RustyPipe, unlocalized: bool) { - let genres = rp.query().music_genres().await.unwrap(); +fn music_genres(rp: RustyPipe, unlocalized: bool) { + let genres = tokio_test::block_on(rp.query().music_genres()).unwrap(); let chill = genres .iter() @@ -2564,9 +2396,8 @@ async fn music_genres(rp: RustyPipe, unlocalized: bool) { #[rstest] #[case::chill("ggMPOg1uX1JOQWZFeDByc2Jm", "Chill")] #[case::pop("ggMPOg1uX1lMbVZmbzl6NlJ3", "Pop")] -#[tokio::test] -async fn music_genre(#[case] id: &str, #[case] name: &str, rp: RustyPipe, unlocalized: bool) { - let genre = rp.query().music_genre(id).await.unwrap(); +fn music_genre(#[case] id: &str, #[case] name: &str, rp: RustyPipe, unlocalized: bool) { + let genre = tokio_test::block_on(rp.query().music_genre(id)).unwrap(); fn check_music_genre( genre: MusicGenre, @@ -2611,19 +2442,14 @@ async fn music_genre(#[case] id: &str, #[case] name: &str, rp: RustyPipe, unloca } for (id, name) in subgenres { - let genre = rp.query().music_genre(&id).await.unwrap(); + let genre = tokio_test::block_on(rp.query().music_genre(&id)).unwrap(); check_music_genre(genre, &id, &name, unlocalized); } } #[rstest] -#[tokio::test] -async fn music_genre_not_found(rp: RustyPipe) { - let err = rp - .query() - .music_genre("ggMPOg1uX1JOQWZFeDByc2zz") - .await - .unwrap_err(); +fn music_genre_not_found(rp: RustyPipe) { + let err = tokio_test::block_on(rp.query().music_genre("ggMPOg1uX1JOQWZFeDByc2zz")).unwrap_err(); assert!( matches!(err, Error::Extraction(ExtractionError::NotFound { .. })), @@ -2635,17 +2461,15 @@ async fn music_genre_not_found(rp: RustyPipe) { const VISITOR_DATA_SEARCH_CHANNEL_HANDLES: &str = "CgszYlc1Yk1WZGRCSSjrwOSbBg%3D%3D"; -#[tokio::test] -async fn ab3_search_channel_handles() { +#[test] +fn ab3_search_channel_handles() { let rp = rp_visitor_data(VISITOR_DATA_SEARCH_CHANNEL_HANDLES); - rp.query() - .search_filter::( - "test", - &SearchFilter::new().item_type(search_filter::ItemType::Channel), - ) - .await - .unwrap(); + tokio_test::block_on(rp.query().search_filter::( + "test", + &SearchFilter::new().item_type(search_filter::ItemType::Channel), + )) + .unwrap(); } //#MISCELLANEOUS @@ -2653,12 +2477,8 @@ async fn ab3_search_channel_handles() { #[rstest] #[case::desktop(ContinuationEndpoint::Browse)] #[case::music(ContinuationEndpoint::MusicBrowse)] -#[tokio::test] -async fn invalid_ctoken(#[case] ep: ContinuationEndpoint, rp: RustyPipe) { - let e = rp - .query() - .continuation::("Abcd", ep, None) - .await +fn invalid_ctoken(#[case] ep: ContinuationEndpoint, rp: RustyPipe) { + let e = tokio_test::block_on(rp.query().continuation::("Abcd", ep, None)) .unwrap_err(); match e { @@ -2737,7 +2557,8 @@ fn assert_gteo(a: Option, b: T, msg: &str) { } /// Assert that the paginator produces at least n pages -async fn assert_next>( +#[track_caller] +fn assert_next>( paginator: Paginator, query: Q, min_items: usize, @@ -2751,7 +2572,9 @@ async fn assert_next>( } for i in 0..n_pages { - p = p.next(query).await.unwrap().expect("paginator exhausted"); + p = tokio_test::block_on(p.next(query)) + .unwrap() + .expect("paginator exhausted"); assert_gte( p.items.len(), min_items, @@ -2761,14 +2584,15 @@ async fn assert_next>( } /// Assert that the paginator produces at least n items -async fn assert_next_items>( +#[track_caller] +fn assert_next_items>( paginator: Paginator, query: Q, n_items: usize, ) { let mut p = paginator; let query = query.as_ref(); - p.extend_limit(query, n_items).await.unwrap(); + tokio_test::block_on(p.extend_limit(query, n_items)).unwrap(); assert_gte(p.items.len(), n_items, "items"); }