playlist/
playlist.rs

1use std::env;
2
3use yt_api::{
4	playlistitems::{Error, PlaylistItems},
5	ApiKey,
6};
7
8/// prints the first answer of a search query
9fn main() -> Result<(), Error> {
10	futures::executor::block_on(async {
11		// take api key from enviroment variable
12		let key = ApiKey::new(&env::var("YT_API_KEY").expect("YT_API_KEY env-var not found"));
13
14		// create the PlaylistItems struct for some playlist ID
15		let result = PlaylistItems::new(key)
16			.playlist_id("PLVvjrrRCBy2JSHf9tGxGKJ-bYAN_uDCUL")
17			.max_results(50)
18			.await?;
19
20		for item in result.items {
21			println!(
22				"https://youtube.com/watch?v={}",
23				item.snippet.resource_id.video_id
24			);
25		}
26
27		Ok(())
28	})
29}