Module rustube::blocking[][src]

This is supported on crate feature blocking only.

Blocking wrappers for using rustube in a synchronous context.

Downloading videos with the blocking API works exactly like described for the asynchronous API in the crate documentation, and in the Video documentation, except for the last step:

let url = Url::parse("https://youtube.com/watch?iv=5jlI4uzZGjU")?;
let path_to_video = Video::from_url(&url)?
   .best_quality()
   .unwrap()
   .blocking_download()?;

As you can see, there’s no corresponding synchronous version of Stream, but only a few methods prefixed with blocking_. This is not the most beautiful solution and may change in the future.

Another option is using the block macro:

let url = Url::parse("https://youtube.com/watch?iv=5jlI4uzZGjU")?;
let video = Video::from_url(&url)?;
let best_quality = video.best_quality().unwrap();
 
let path_to_video = block!(best_quality.download());

This macro will utilize the Runtime created for you by rustube, and block on the provided future (You can also use it for other asynchronous stuff, not related to rustube).

Structs

Video

A synchronous wrapper around Video.

VideoDescrambler

A synchronous wrapper around VideoDescrambler.

VideoFetcher

A synchronous wrapper around VideoFetcher.

Statics

RT

A Runtime for executing asynchronous code.

Functions

download_best_qualitydownload and regex

A synchronous wrapper around download_best_quality.

download_worst_qualitydownload and regex

A synchronous wrapper around download_worst_quality.