complex_search/
complex_search.rs1use std::env;
2
3use yt_api::{
4 search::{Error, ItemType, SearchList, VideoLocation},
5 ApiKey,
6};
7
8fn main() -> Result<(), Error> {
10 futures::executor::block_on(async {
11 let key = ApiKey::new(&env::var("YT_API_KEY").expect("YT_API_KEY env-var not found"));
13
14 let result = SearchList::new(key)
16 .q("rust lang")
17 .max_results(1)
18 .item_type(ItemType::Video)
19 .location(VideoLocation::new(40.73061, -73.93524))
20 .location_radius("100km")
21 .video_embeddable()
22 .await?;
23
24 println!(
26 "Title: \"{}\"",
27 result.items[0].snippet.title.as_ref().unwrap()
28 );
29 println!(
30 "https://youtube.com/watch?v={}",
31 result.items[0].id.video_id.as_ref().unwrap()
32 );
33
34 Ok(())
35 })
36}