Skip to content

Commit

Permalink
Merge pull request #2 from SL9-1994/develop
Browse files Browse the repository at this point in the history
closed #1 add:✨ Added video download function.
  • Loading branch information
SL9-1994 authored Apr 18, 2024
2 parents 363f67b + 88032fe commit ad44cac
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
fn main() {
println!("Hello, world!");
use rusty_ytdl::{Video, VideoOptions, VideoQuality, VideoSearchOptions};
use std::env;

#[tokio::main]
async fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("Please provide a video URL as a command line argument.");
return;
}

let video_url = &args[1];

let video_options = VideoOptions {
quality: VideoQuality::Highest,
filter: VideoSearchOptions::VideoAudio,
..Default::default()
};

// BadApple
let video = Video::new_with_options(&*video_url, video_options).unwrap();

let stream = video.stream().await.unwrap();

while let Some(chunk) = stream.chunk().await.unwrap() {
println!("{:#?}", chunk);
}

// let music_path = std::path::Path::new(r"badapple.mp3");
// video.download(music_path).await.unwrap();
let video_path = std::path::Path::new(r"badapple.mkv");
video.download(video_path).await.unwrap();
}

0 comments on commit ad44cac

Please sign in to comment.