add asked questions to project.toml
This commit is contained in:
parent
1e7f5f95cd
commit
8b57b97c80
1 changed files with 57 additions and 5 deletions
62
src/main.rs
62
src/main.rs
|
@ -172,9 +172,15 @@ struct ProjectSource {
|
||||||
start: Option<Time>,
|
start: Option<Time>,
|
||||||
#[serde_as(as = "Option<DisplayFromStr>")]
|
#[serde_as(as = "Option<DisplayFromStr>")]
|
||||||
end: Option<Time>,
|
end: Option<Time>,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
#[serde_as(as = "Vec<(DisplayFromStr, DisplayFromStr)>")]
|
#[serde_as(as = "Vec<(DisplayFromStr, DisplayFromStr)>")]
|
||||||
fast: Vec<(Time, Time)>,
|
fast: Vec<(Time, Time)>,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
#[serde_as(as = "Vec<(DisplayFromStr, DisplayFromStr, _)>")]
|
||||||
|
questions: Vec<(Time, Time, String)>,
|
||||||
|
|
||||||
metadata: Option<ProjectSourceMetadata>
|
metadata: Option<ProjectSourceMetadata>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,10 +204,22 @@ struct ProjectSourceMetadata {
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize)]
|
#[derive(Default, Deserialize, Serialize)]
|
||||||
struct ProjectProgress {
|
struct ProjectProgress {
|
||||||
|
#[serde(default)]
|
||||||
preprocessed: bool,
|
preprocessed: bool,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
asked_start_end: bool,
|
asked_start_end: bool,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
asked_fast: bool,
|
asked_fast: bool,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
asked_questions: bool,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
rendered: bool,
|
rendered: bool,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
transcoded: BTreeSet<Resolution>
|
transcoded: BTreeSet<Resolution>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,10 +227,15 @@ fn ask(question: impl Display) -> String {
|
||||||
let mut stdout = io::stdout().lock();
|
let mut stdout = io::stdout().lock();
|
||||||
let mut stdin = io::stdin().lock();
|
let mut stdin = io::stdin().lock();
|
||||||
|
|
||||||
writeln!(stdout, "{} {question}", style("?").bold().yellow()).unwrap();
|
write!(
|
||||||
let mut line = String::new();
|
stdout,
|
||||||
write!(stdout, "{} ", style(">").cyan()).unwrap();
|
"{} {} ",
|
||||||
|
style(question).bold().magenta(),
|
||||||
|
style(">").cyan()
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
stdout.flush().unwrap();
|
stdout.flush().unwrap();
|
||||||
|
let mut line = String::new();
|
||||||
stdin.read_line(&mut line).unwrap();
|
stdin.read_line(&mut line).unwrap();
|
||||||
line.trim().to_owned()
|
line.trim().to_owned()
|
||||||
}
|
}
|
||||||
|
@ -288,7 +311,11 @@ fn main() {
|
||||||
print!(" {}", style(f).bold().yellow());
|
print!(" {}", style(f).bold().yellow());
|
||||||
}
|
}
|
||||||
println!();
|
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()
|
.split_ascii_whitespace()
|
||||||
.map(String::from)
|
.map(String::from)
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -308,6 +335,7 @@ fn main() {
|
||||||
start: None,
|
start: None,
|
||||||
end: None,
|
end: None,
|
||||||
fast: Vec::new(),
|
fast: Vec::new(),
|
||||||
|
questions: Vec::new(),
|
||||||
metadata: None
|
metadata: None
|
||||||
},
|
},
|
||||||
progress: Default::default()
|
progress: Default::default()
|
||||||
|
@ -366,6 +394,26 @@ fn main() {
|
||||||
fs::write(&project_path, toml::to_string(&project).unwrap().as_bytes()).unwrap();
|
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
|
// render the video
|
||||||
let mut videos = Vec::new();
|
let mut videos = Vec::new();
|
||||||
videos.push(if project.progress.rendered {
|
videos.push(if project.progress.rendered {
|
||||||
|
@ -406,6 +454,10 @@ fn main() {
|
||||||
);
|
);
|
||||||
println!(" Videos:");
|
println!(" Videos:");
|
||||||
for v in &videos {
|
for v in &videos {
|
||||||
println!(" {} {v}", style("->").bold().cyan());
|
println!(
|
||||||
|
" {} {}",
|
||||||
|
style("->").bold().cyan(),
|
||||||
|
style(v).bold().yellow()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue