Created
April 2, 2018 22:46
-
-
Save felix-d/037d7c53aa84fc72f0ca4bfe031a4674 to your computer and use it in GitHub Desktop.
Revisions
-
felix-d created this gist
Apr 2, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ 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);