diff --git a/src/main.rs b/src/main.rs index 4a825159083f521fc4f0430ace8e115cef392054..5b163f27e313f6f2a75b4f06200d4e4a5904a4ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -172,9 +172,15 @@ struct ProjectSource { start: Option<Time>, #[serde_as(as = "Option<DisplayFromStr>")] end: Option<Time>, + + #[serde(default)] #[serde_as(as = "Vec<(DisplayFromStr, DisplayFromStr)>")] fast: Vec<(Time, Time)>, + #[serde(default)] + #[serde_as(as = "Vec<(DisplayFromStr, DisplayFromStr, _)>")] + questions: Vec<(Time, Time, String)>, + metadata: Option<ProjectSourceMetadata> } @@ -198,10 +204,22 @@ struct ProjectSourceMetadata { #[derive(Default, Deserialize, Serialize)] struct ProjectProgress { + #[serde(default)] preprocessed: bool, + + #[serde(default)] asked_start_end: bool, + + #[serde(default)] asked_fast: bool, + + #[serde(default)] + asked_questions: bool, + + #[serde(default)] rendered: bool, + + #[serde(default)] transcoded: BTreeSet<Resolution> } @@ -209,10 +227,15 @@ fn ask(question: impl Display) -> String { let mut stdout = io::stdout().lock(); let mut stdin = io::stdin().lock(); - writeln!(stdout, "{} {question}", style("?").bold().yellow()).unwrap(); - let mut line = String::new(); - write!(stdout, "{} ", style(">").cyan()).unwrap(); + write!( + stdout, + "{} {} ", + style(question).bold().magenta(), + style(">").cyan() + ) + .unwrap(); stdout.flush().unwrap(); + let mut line = String::new(); stdin.read_line(&mut line).unwrap(); line.trim().to_owned() } @@ -288,7 +311,11 @@ fn main() { print!(" {}", style(f).bold().yellow()); } println!(); - files = ask("Which source files would you like to use? (specify multiple files separated by whitespace)") + println!( + "{} Which source files would you like to use? (specify multiple files separated by whitespace)", + style("?").bold().yellow() + ); + files = ask("files") .split_ascii_whitespace() .map(String::from) .collect(); @@ -308,6 +335,7 @@ fn main() { start: None, end: None, fast: Vec::new(), + questions: Vec::new(), metadata: None }, progress: Default::default() @@ -366,6 +394,26 @@ fn main() { fs::write(&project_path, toml::to_string(&project).unwrap().as_bytes()).unwrap(); } + // ask the user about questions from the audience that should be subtitled + if !project.progress.asked_questions { + println!( + "{} In which sections of the video were questions asked you want subtitles for? (0 to finish)", + style("?").bold().yellow() + ); + loop { + let start = ask_time("from"); + if start.seconds == 0 && start.micros == 0 { + break; + } + let end = ask_time("to "); + let text = ask("text"); + project.source.questions.push((start, end, text)); + } + project.progress.asked_questions = true; + + fs::write(&project_path, toml::to_string(&project).unwrap().as_bytes()).unwrap(); + } + // render the video let mut videos = Vec::new(); videos.push(if project.progress.rendered { @@ -406,6 +454,10 @@ fn main() { ); println!(" Videos:"); for v in &videos { - println!(" {} {v}", style("->").bold().cyan()); + println!( + " {} {}", + style("->").bold().cyan(), + style(v).bold().yellow() + ); } }