diff --git a/clients/terminal/src/main.rs b/clients/terminal/src/main.rs index b71373f..2faeb99 100644 --- a/clients/terminal/src/main.rs +++ b/clients/terminal/src/main.rs @@ -59,7 +59,7 @@ fn run() -> Result<(), Box> { .long("mime_type") .value_name("MIME_TYPE") .help("Mime type (e.g., video/mp4)") - .required(true) + .required_unless_present("file") .takes_value(true) ) .arg(Arg::with_name("file") @@ -189,9 +189,23 @@ fn run() -> Result<(), Box> { let mut join_handle: Option>> = None; if let Some(play_matches) = matches.subcommand_matches("play") { + let file_path = play_matches.value_of("file"); + let mime_type = match play_matches.value_of("mime_type") { Some(s) => s.to_string(), - _ => return Err("MIME type is required.".into()) + _ => { + if file_path.is_none() { + return Err("MIME type is required.".into()); + } + match file_path.unwrap().split('.').last() { + Some("mkv") => "video/x-matroska".to_string(), + Some("mov") => "video/quicktime".to_string(), + Some("mp4") | Some("m4v") => "video/mp4".to_string(), + Some("mpg") | Some("mpeg") => "video/mpeg".to_string(), + Some("webm") => "video/webm".to_string(), + _ => return Err("MIME type is required.".into()), + } + } }; let time = match play_matches.value_of("timestamp") { @@ -216,8 +230,6 @@ fn run() -> Result<(), Box> { } ).collect::>()); - let file_path = play_matches.value_of("file"); - let mut play_message = if let Some(file_path) = file_path { match local_ip { Some(lip) => {