Created
April 2, 2018 22:46
-
-
Save felix-d/037d7c53aa84fc72f0ca4bfe031a4674 to your computer and use it in GitHub Desktop.
Downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let video_file_regex = Regex::new(r"https://.*\.ts").unwrap(); | |
let mut result_video_file = File::create("result.ts")?; | |
let futures: Vec<_> = video_file_regex.find_iter(&hd_playlist_content).map(|capture| { | |
let video_file_link = capture.as_str(); | |
let response = client.get(video_file_link.parse().unwrap()); | |
response.unwrap().body().concat2() | |
}).collect(); | |
let all = futures::stream::futures_ordered(futures); | |
let all = all.and_then(|bytes: hyper::Chunk| { | |
result_video_file.write_all(&bytes).unwrap(); | |
Ok(()) | |
}).for_each(|_| Ok(())); | |
core.run(all); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment