blob_dl/
dispatcher.rs

1use crate::analyzer;
2use crate::parser;
3use crate::assembling;
4use crate::error::BlobResult;
5use crate::run;
6
7/// Calls the builder function according to what the url refers to (video/playlist), then it runs the ytdl-command and handles errors
8pub fn dispatch(config: &parser::CliConfig) -> BlobResult<()> {
9    // Parse what the url refers to
10    let download_option = analyzer::analyze_url(config.url());
11
12    // Generate a command according to the user's preferences
13    let mut command_and_config = assembling::generate_command(config.url(), &download_option?)? ;
14
15    if config.show_command() {
16        println!("Command generated by blob-dl: {:?}", command_and_config.0);
17    }
18
19    // Run the command
20    run::run_and_observe(&mut command_and_config.0, &command_and_config.1, config.verbosity());
21
22    Ok(())
23}
24