Add crates.io metadata

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/1/head
trivernis 4 years ago
parent 03f091b639
commit 7cbd3b2b23
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -3,6 +3,9 @@ name = "youtube-metadata"
version = "0.1.0"
authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018"
description = "YouTube video metadata fetcher"
readme = "README.md"
license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

@ -3,6 +3,26 @@ use crate::parsing::video_information::parse_video_information;
use crate::types::VideoInformation;
/// Returns information about a video
/// ```
/// use youtube_metadata::get_video_information;
/// let information = get_video_information("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
/// .await
/// .unwrap();
/// assert_eq!(information.id, "dQw4w9WgXcQ".to_string());
/// assert_eq!(
/// information.url,
/// "https://www.youtube.com/watch?v=dQw4w9WgXcQ".to_string()
/// );
/// assert_eq!(information.uploader, "RickAstleyVEVO".to_string());
/// assert_eq!(
/// information.title,
/// "Rick Astley - Never Gonna Give You Up (Video)".to_string()
/// );
/// assert_eq!(
/// information.thumbnail,
/// Some("https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg".to_string())
/// );
/// ```
pub async fn get_video_information(url: &str) -> YoutubeResult<VideoInformation> {
let response = reqwest::get(url).await?;
let response_text = response.text().await?;

Loading…
Cancel
Save