use std::env;
use yt_api::{
search::{Error, ItemType, SearchList, VideoLocation},
ApiKey,
};
fn main() -> Result<(), Error> {
futures::executor::block_on(async {
let key = ApiKey::new(&env::var("YT_API_KEY").expect("YT_API_KEY env-var not found"));
let result = SearchList::new(key)
.q("rust lang")
.max_results(1)
.item_type(ItemType::Video)
.location(VideoLocation::new(40.73061, -73.93524))
.location_radius("100km")
.video_embeddable()
.await?;
println!(
"Title: \"{}\"",
result.items[0].snippet.title.as_ref().unwrap()
);
println!(
"https://youtube.com/watch?v={}",
result.items[0].id.video_id.as_ref().unwrap()
);
Ok(())
})
}