Add batch and video-folder timing reports with Ontime groups
This commit is contained in:
parent
673f2a6be0
commit
637b5eb7e6
|
|
@ -10,7 +10,7 @@ app, and Python tools for prototyping and document exports.
|
|||
## Quick start
|
||||
|
||||
On Windows, extract the portable ZIP and open `pptx-reporter-gui.exe`.
|
||||
Drop a presentation into the window, select report formats, and generate.
|
||||
Drop PPTX files or a video folder into the window, select report formats, and generate.
|
||||
Keep the bundled `ffprobe.exe` beside the app.
|
||||
|
||||
On macOS 13+, extract the portable ZIP for Apple Silicon (`aarch64`) or Intel
|
||||
|
|
@ -22,6 +22,7 @@ To run from source:
|
|||
```sh
|
||||
cargo run --locked --bin pptx-reporter-gui
|
||||
cargo run --locked --bin pptx-reporter -- presentation.pptx --report all
|
||||
cargo run --locked --bin pptx-reporter -- ./show --timings-only --report ontime
|
||||
python3 tools/exporter.py presentation.pptx --output pdf,images
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ pub fn assemble(source: &Path, mut videos: Vec<Video>, discovery: &archive::Disc
|
|||
)
|
||||
});
|
||||
Report {
|
||||
groups: vec![],
|
||||
presentation: source
|
||||
.file_name()
|
||||
.unwrap_or_default()
|
||||
|
|
@ -196,8 +197,20 @@ pub fn assemble(source: &Path, mut videos: Vec<Video>, discovery: &archive::Disc
|
|||
notes: NOTES.iter().map(|s| (*s).into()).collect(),
|
||||
}
|
||||
}
|
||||
pub fn run(options: &Options, cancel: &AtomicBool, mut emit: impl FnMut(Event)) -> Result<Outcome> {
|
||||
pub fn run(options: &Options, cancel: &AtomicBool, emit: impl FnMut(Event)) -> Result<Outcome> {
|
||||
options.validate()?;
|
||||
if options.source.is_dir() || !options.additional_sources.is_empty() {
|
||||
return crate::inputs::run(options, cancel, emit);
|
||||
}
|
||||
run_pptx(options, cancel, emit, true)
|
||||
}
|
||||
|
||||
pub(crate) fn run_pptx(
|
||||
options: &Options,
|
||||
cancel: &AtomicBool,
|
||||
mut emit: impl FnMut(Event),
|
||||
publish: bool,
|
||||
) -> Result<Outcome> {
|
||||
cancelled(cancel)?;
|
||||
emit(Event::step("Scanning presentation", 0, 0));
|
||||
let mut zip =
|
||||
|
|
@ -320,6 +333,36 @@ pub fn run(options: &Options, cancel: &AtomicBool, mut emit: impl FnMut(Event))
|
|||
return Ok(outcome);
|
||||
}
|
||||
let report = assemble(&options.source, videos, &discovered);
|
||||
if !publish {
|
||||
outcome.report = Some(report);
|
||||
return Ok(outcome);
|
||||
}
|
||||
write_reports(options, cancel, &mut emit, report, outcome)
|
||||
}
|
||||
|
||||
pub(crate) fn write_reports(
|
||||
options: &Options,
|
||||
cancel: &AtomicBool,
|
||||
emit: &mut impl FnMut(Event),
|
||||
report: Report,
|
||||
mut outcome: Outcome,
|
||||
) -> Result<Outcome> {
|
||||
#[cfg(not(feature = "pdf"))]
|
||||
anyhow::ensure!(
|
||||
!options
|
||||
.formats
|
||||
.iter()
|
||||
.any(|f| f == "pdf" || f == "pdf-dense"),
|
||||
"This build has no PDF support."
|
||||
);
|
||||
let output = &outcome.output;
|
||||
for dir in [output.clone(), output.join("reports")] {
|
||||
anyhow::ensure!(
|
||||
!dir.is_symlink(),
|
||||
"Refusing output directory symlink: {}",
|
||||
dir.display()
|
||||
);
|
||||
}
|
||||
// Generate and compile everything before replacing any report.
|
||||
let staging = tempfile::tempdir()?;
|
||||
let mut requested = options.formats.clone();
|
||||
|
|
|
|||
|
|
@ -31,21 +31,24 @@ fn config_path() -> Option<PathBuf> {
|
|||
directories::ProjectDirs::from("com", "beffroi", "pptx-reporter")
|
||||
.map(|d| d.config_dir().join("settings.json"))
|
||||
}
|
||||
pub fn accept_drop(paths: impl IntoIterator<Item = PathBuf>) -> Result<PathBuf, String> {
|
||||
pub fn accept_drop(paths: impl IntoIterator<Item = PathBuf>) -> Result<Vec<PathBuf>, String> {
|
||||
let paths: Vec<_> = paths.into_iter().collect();
|
||||
if paths.len() != 1 {
|
||||
return Err("Drop one PPTX presentation at a time.".into());
|
||||
if paths.is_empty() {
|
||||
return Err("Choose PPTX files or a folder.".into());
|
||||
}
|
||||
let path = paths.into_iter().next().unwrap();
|
||||
if !path.is_file()
|
||||
|| !path
|
||||
.extension()
|
||||
.is_some_and(|e| e.eq_ignore_ascii_case("pptx"))
|
||||
{
|
||||
return Err("Choose a .pptx presentation.".into());
|
||||
for path in &paths {
|
||||
if !path.is_dir()
|
||||
&& !(path.is_file()
|
||||
&& path
|
||||
.extension()
|
||||
.is_some_and(|e| e.eq_ignore_ascii_case("pptx")))
|
||||
{
|
||||
return Err("Choose PPTX files or a folder.".into());
|
||||
}
|
||||
}
|
||||
Ok(path)
|
||||
Ok(paths)
|
||||
}
|
||||
|
||||
fn format_label(format: &str) -> &str {
|
||||
match format {
|
||||
"md" => "Markdown",
|
||||
|
|
@ -245,8 +248,9 @@ impl App {
|
|||
);
|
||||
} else {
|
||||
match accept_drop(drops) {
|
||||
Ok(path) => {
|
||||
self.source = path.display().to_string();
|
||||
Ok(paths) => {
|
||||
self.source = paths[0].display().to_string();
|
||||
self.preferences.options.additional_sources = paths[1..].to_vec();
|
||||
self.error = None;
|
||||
}
|
||||
Err(e) => self.error = Some(e),
|
||||
|
|
@ -267,18 +271,31 @@ impl App {
|
|||
let selected = !self.source.is_empty();
|
||||
let title = if selected {
|
||||
std::path::Path::new(&self.source).file_name().unwrap_or_default().to_string_lossy().into_owned()
|
||||
} else { "Drop a PPTX here".into() };
|
||||
} else { "Drop PPTX files or a folder here".into() };
|
||||
ui.label(RichText::new(title).size(22.0).strong());
|
||||
ui.weak(if selected { "Drop another presentation to change your selection." } else { "Drag a file into this window, or choose one below." });
|
||||
if ui.button("Choose presentation…").clicked()
|
||||
&& let Some(file) = rfd::FileDialog::new().add_filter("PowerPoint",&["pptx"]).pick_file() {
|
||||
ui.weak(if selected { "Drop another presentation to change your selection." } else { "Choose PPTX files, a video folder, or a folder of presentations." });
|
||||
if ui.button("Choose presentations…").clicked()
|
||||
&& let Some(files) = rfd::FileDialog::new().add_filter("PowerPoint",&["pptx"]).pick_files()
|
||||
&& let Some(file) = files.first() {
|
||||
self.source = file.display().to_string();
|
||||
self.preferences.options.additional_sources = files[1..].to_vec();
|
||||
}
|
||||
if ui.button("Choose folder…").clicked()
|
||||
&& let Some(folder) = rfd::FileDialog::new().pick_folder() {
|
||||
self.source = folder.display().to_string();
|
||||
self.preferences.options.additional_sources.clear();
|
||||
}
|
||||
if ui.add(egui::TextEdit::singleline(&mut self.source).desired_width(f32::INFINITY).hint_text("PPTX or folder path")).changed() {
|
||||
self.preferences.options.additional_sources.clear();
|
||||
}
|
||||
if !self.preferences.options.additional_sources.is_empty() {
|
||||
ui.label(format!("{} selected inputs — combined in filename order", self.preferences.options.additional_sources.len() + 1));
|
||||
for path in &self.preferences.options.additional_sources { ui.weak(path.display().to_string()); }
|
||||
}
|
||||
ui.add(egui::TextEdit::singleline(&mut self.source).desired_width(f32::INFINITY).hint_text("Presentation path"));
|
||||
if !self.preferences.recent.is_empty() {
|
||||
egui::ComboBox::from_label("Recent presentations").selected_text("Choose…").show_ui(ui, |ui| {
|
||||
for path in &self.preferences.recent {
|
||||
if ui.selectable_label(false,path.display().to_string()).clicked() { self.source = path.display().to_string(); }
|
||||
if ui.selectable_label(false,path.display().to_string()).clicked() { self.source = path.display().to_string(); self.preferences.options.additional_sources.clear(); }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,256 @@
|
|||
//! Filename-ordered presentations and video folders sharing the reporting pipeline.
|
||||
use crate::{
|
||||
archive,
|
||||
engine::{self, Event, Outcome},
|
||||
model::*,
|
||||
};
|
||||
use anyhow::{Context, Result};
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
sync::atomic::AtomicBool,
|
||||
};
|
||||
|
||||
fn children(path: &Path) -> Result<Vec<PathBuf>> {
|
||||
let mut paths = fs::read_dir(path)?
|
||||
.map(|e| e.map(|e| e.path()))
|
||||
.collect::<std::io::Result<Vec<_>>>()?;
|
||||
paths.sort_by(|a, b| a.file_name().cmp(&b.file_name()).then_with(|| a.cmp(b)));
|
||||
Ok(paths)
|
||||
}
|
||||
fn video(path: &Path) -> bool {
|
||||
path.is_file() && archive::is_video(&path.to_string_lossy())
|
||||
}
|
||||
fn pptx(path: &Path) -> bool {
|
||||
path.is_file()
|
||||
&& path
|
||||
.extension()
|
||||
.is_some_and(|e| e.eq_ignore_ascii_case("pptx"))
|
||||
}
|
||||
/// Expand one level of batch folders; video folders are individual presentations.
|
||||
pub fn discover(options: &Options) -> Result<Vec<PathBuf>> {
|
||||
let output = options.output_dir();
|
||||
let mut sources = vec![];
|
||||
for path in std::iter::once(&options.source).chain(&options.additional_sources) {
|
||||
if path.is_file() {
|
||||
sources.push(path.clone());
|
||||
continue;
|
||||
}
|
||||
let items = children(path)?;
|
||||
let has_videos = items.iter().any(|p| video(p));
|
||||
let mut groups = vec![];
|
||||
for item in &items {
|
||||
if item == &output || item.is_symlink() {
|
||||
continue;
|
||||
}
|
||||
if pptx(item) || (item.is_dir() && children(item)?.iter().any(|p| video(p))) {
|
||||
groups.push(item.clone());
|
||||
}
|
||||
}
|
||||
anyhow::ensure!(
|
||||
!has_videos || groups.is_empty(),
|
||||
"Folder mixes videos and presentations: {}. Select individual inputs instead.",
|
||||
path.display()
|
||||
);
|
||||
if has_videos {
|
||||
sources.push(path.clone());
|
||||
} else {
|
||||
sources.extend(groups);
|
||||
}
|
||||
}
|
||||
sources.sort_by(|a, b| a.file_name().cmp(&b.file_name()).then_with(|| a.cmp(b)));
|
||||
let mut seen = std::collections::BTreeSet::new();
|
||||
sources.retain(|p| seen.insert(fs::canonicalize(p).unwrap_or_else(|_| p.clone())));
|
||||
Ok(sources)
|
||||
}
|
||||
fn folder(options: &Options, cancel: &AtomicBool, emit: &mut impl FnMut(Event)) -> Result<Outcome> {
|
||||
let paths: Vec<_> = children(&options.source)?
|
||||
.into_iter()
|
||||
.filter(|p| video(p))
|
||||
.collect();
|
||||
let ffprobe = if options.extract_only {
|
||||
None
|
||||
} else {
|
||||
Some(engine::find_ffprobe(options.ffprobe.as_deref())?)
|
||||
};
|
||||
let output = options.output_dir();
|
||||
for dir in [&output, &output.join("videos")] {
|
||||
anyhow::ensure!(
|
||||
!dir.is_symlink(),
|
||||
"Refusing output directory symlink: {}",
|
||||
dir.display()
|
||||
);
|
||||
}
|
||||
let mut videos = vec![];
|
||||
for (i, path) in paths.iter().enumerate() {
|
||||
engine::cancelled(cancel)?;
|
||||
let name = path
|
||||
.file_name()
|
||||
.context("Missing video filename")?
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
emit(Event::step(format!("Processing {name}"), i, paths.len()));
|
||||
let dest = output.join("videos").join(&name);
|
||||
if !options.timings_only {
|
||||
anyhow::ensure!(
|
||||
!dest.is_symlink(),
|
||||
"Refusing media symlink: {}",
|
||||
dest.display()
|
||||
);
|
||||
anyhow::ensure!(
|
||||
fs::canonicalize(path).ok() != fs::canonicalize(&dest).ok(),
|
||||
"Output would replace source video: {}",
|
||||
path.display()
|
||||
);
|
||||
if !dest.exists() || options.overwrite {
|
||||
fs::create_dir_all(dest.parent().unwrap())?;
|
||||
let mut temp = tempfile::NamedTempFile::new_in(dest.parent().unwrap())?;
|
||||
std::io::copy(&mut fs::File::open(path)?, &mut temp)?;
|
||||
temp.persist(&dest).map_err(|e| e.error)?;
|
||||
}
|
||||
}
|
||||
if let Some(exe) = &ffprobe {
|
||||
let (duration_seconds, resolution, codec) = engine::probe(exe, path, cancel)?;
|
||||
if duration_seconds.is_none() {
|
||||
emit(Event {
|
||||
warning: true,
|
||||
..Event::step(format!("Duration unknown for {name}"), i, paths.len())
|
||||
});
|
||||
}
|
||||
videos.push(Video {
|
||||
slides: vec![i + 1],
|
||||
duration_seconds,
|
||||
resolution,
|
||||
codec,
|
||||
archive_path: name.clone(),
|
||||
size_bytes: fs::metadata(path)?.len(),
|
||||
extracted_file: (!options.timings_only).then(|| format!("../videos/{name}")),
|
||||
name,
|
||||
});
|
||||
}
|
||||
emit(Event::step(
|
||||
format!("Processed {}", path.display()),
|
||||
i + 1,
|
||||
paths.len(),
|
||||
));
|
||||
}
|
||||
Ok(Outcome {
|
||||
report: (!options.extract_only)
|
||||
.then(|| engine::assemble(&options.source, videos, &archive::Discovery::default())),
|
||||
paths: if options.extract_only {
|
||||
vec![output.join("videos")]
|
||||
} else {
|
||||
vec![]
|
||||
},
|
||||
output,
|
||||
})
|
||||
}
|
||||
pub fn run(options: &Options, cancel: &AtomicBool, mut emit: impl FnMut(Event)) -> Result<Outcome> {
|
||||
engine::cancelled(cancel)?;
|
||||
let sources = discover(options)?;
|
||||
let output = options.output_dir();
|
||||
anyhow::ensure!(
|
||||
!output.is_symlink(),
|
||||
"Refusing output directory symlink: {}",
|
||||
output.display()
|
||||
);
|
||||
let batch = sources.len() > 1 || sources.first() != Some(&options.source);
|
||||
let mut outcome = Outcome {
|
||||
output: output.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
let mut combined = Report {
|
||||
presentation: options
|
||||
.source
|
||||
.file_name()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.into_owned(),
|
||||
notes: NOTES.iter().map(|s| (*s).into()).collect(),
|
||||
..Default::default()
|
||||
};
|
||||
if !options.additional_sources.is_empty() {
|
||||
combined.presentation = "Batch timings".into();
|
||||
}
|
||||
for (i, source) in sources.iter().enumerate() {
|
||||
engine::cancelled(cancel)?;
|
||||
emit(Event::step(
|
||||
format!("Source {}/{}: {}", i + 1, sources.len(), source.display()),
|
||||
i,
|
||||
sources.len(),
|
||||
));
|
||||
let label = source
|
||||
.file_name()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
let directory = format!("{:03}", i + 1);
|
||||
let child = Options {
|
||||
source: source.clone(),
|
||||
additional_sources: vec![],
|
||||
output: Some(if batch {
|
||||
output.join(&directory)
|
||||
} else {
|
||||
output.clone()
|
||||
}),
|
||||
..options.clone()
|
||||
};
|
||||
let result = if source.is_dir() {
|
||||
folder(&child, cancel, &mut emit)
|
||||
} else {
|
||||
engine::run_pptx(&child, cancel, &mut emit, false)
|
||||
}
|
||||
.with_context(|| format!("Processing {}", source.display()))?;
|
||||
outcome.paths.extend(result.paths);
|
||||
let Some(mut report) = result.report else {
|
||||
continue;
|
||||
};
|
||||
if batch {
|
||||
combined.groups.push(ReportGroup {
|
||||
title: label.clone(),
|
||||
start: combined.playbacks.len(),
|
||||
end: combined.playbacks.len() + report.playbacks.len(),
|
||||
});
|
||||
let qualify = |v: &mut Video| {
|
||||
v.name = format!("{label} / {}", v.name);
|
||||
v.archive_path = format!("{directory}/{label}/{}", v.archive_path);
|
||||
v.extracted_file = v
|
||||
.extracted_file
|
||||
.as_ref()
|
||||
.map(|p| format!("../{directory}/{}", p.trim_start_matches("../")));
|
||||
};
|
||||
for v in &mut report.videos {
|
||||
qualify(v);
|
||||
}
|
||||
for p in &mut report.playbacks {
|
||||
qualify(&mut p.video);
|
||||
}
|
||||
if !report.external_media_slides.is_empty() {
|
||||
combined.notes.push(format!(
|
||||
"{label}: external media on local slides {:?} was not downloaded.",
|
||||
report.external_media_slides
|
||||
));
|
||||
}
|
||||
} else {
|
||||
combined.external_media_slides = report.external_media_slides;
|
||||
}
|
||||
combined.embedded_videos += report.embedded_videos;
|
||||
combined.total_size_bytes += report.total_size_bytes;
|
||||
combined.total_duration_seconds += report.total_duration_seconds;
|
||||
combined.total_media_duration_seconds += report.total_media_duration_seconds;
|
||||
combined.known_durations += report.known_durations;
|
||||
combined.known_playback_durations += report.known_playback_durations;
|
||||
combined.videos.extend(report.videos);
|
||||
combined.playbacks.extend(report.playbacks);
|
||||
}
|
||||
if options.extract_only || combined.videos.is_empty() {
|
||||
if outcome.paths.is_empty() {
|
||||
emit(Event {
|
||||
warning: true,
|
||||
..Event::step("No videos; no output created.", 0, 0)
|
||||
});
|
||||
}
|
||||
return Ok(outcome);
|
||||
}
|
||||
engine::write_reports(options, cancel, &mut emit, combined, outcome)
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ pub mod archive;
|
|||
pub mod engine;
|
||||
#[cfg(feature = "desktop")]
|
||||
pub mod gui;
|
||||
pub mod inputs;
|
||||
pub mod model;
|
||||
#[cfg(feature = "pdf")]
|
||||
pub mod pdf;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ use std::{
|
|||
about = "Extract PPTX videos and create timing reports. Launch without arguments for the desktop app."
|
||||
)]
|
||||
struct Cli {
|
||||
presentation: Option<PathBuf>,
|
||||
/// PPTX files, a video folder, or a folder of PPTX files / video folders.
|
||||
presentation: Vec<PathBuf>,
|
||||
#[arg(short, long)]
|
||||
output: Option<PathBuf>,
|
||||
#[arg(long, conflicts_with_all = ["timings_only", "report"])]
|
||||
|
|
@ -32,7 +33,8 @@ struct Cli {
|
|||
}
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let cli = Cli::parse();
|
||||
let Some(source) = cli.presentation else {
|
||||
let mut sources = cli.presentation.into_iter();
|
||||
let Some(source) = sources.next() else {
|
||||
#[cfg(feature = "desktop")]
|
||||
return pptx_reporter::gui::launch();
|
||||
#[cfg(not(feature = "desktop"))]
|
||||
|
|
@ -40,6 +42,7 @@ fn main() -> anyhow::Result<()> {
|
|||
};
|
||||
let options = model::Options {
|
||||
source,
|
||||
additional_sources: sources.collect(),
|
||||
output: cli.output,
|
||||
extract_only: cli.extract_only,
|
||||
timings_only: cli.timings_only,
|
||||
|
|
|
|||
|
|
@ -58,8 +58,16 @@ pub struct Playback {
|
|||
pub original_duration_seconds: Option<f64>,
|
||||
pub ontime_eligible: bool,
|
||||
}
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct ReportGroup {
|
||||
pub title: String,
|
||||
pub start: usize,
|
||||
pub end: usize,
|
||||
}
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
|
||||
pub struct Report {
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub groups: Vec<ReportGroup>,
|
||||
pub presentation: String,
|
||||
pub embedded_videos: usize,
|
||||
pub total_size_bytes: u64,
|
||||
|
|
@ -76,6 +84,7 @@ pub struct Report {
|
|||
#[serde(default)]
|
||||
pub struct Options {
|
||||
pub source: PathBuf,
|
||||
pub additional_sources: Vec<PathBuf>,
|
||||
pub output: Option<PathBuf>,
|
||||
pub extract_only: bool,
|
||||
pub timings_only: bool,
|
||||
|
|
@ -87,6 +96,7 @@ impl Default for Options {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
source: PathBuf::new(),
|
||||
additional_sources: vec![],
|
||||
output: None,
|
||||
extract_only: false,
|
||||
timings_only: false,
|
||||
|
|
@ -113,17 +123,17 @@ impl Options {
|
|||
!(self.extract_only && self.timings_only),
|
||||
"Choose only one extraction mode."
|
||||
);
|
||||
anyhow::ensure!(
|
||||
self.source.is_file(),
|
||||
"Not a file: {}",
|
||||
self.source.display()
|
||||
);
|
||||
anyhow::ensure!(
|
||||
self.source
|
||||
.extension()
|
||||
.is_some_and(|s| s.eq_ignore_ascii_case("pptx")),
|
||||
"Choose a .pptx file."
|
||||
);
|
||||
for source in std::iter::once(&self.source).chain(&self.additional_sources) {
|
||||
anyhow::ensure!(
|
||||
source.is_dir()
|
||||
|| (source.is_file()
|
||||
&& source
|
||||
.extension()
|
||||
.is_some_and(|s| s.eq_ignore_ascii_case("pptx"))),
|
||||
"Choose an existing .pptx file or folder: {}",
|
||||
source.display()
|
||||
);
|
||||
}
|
||||
anyhow::ensure!(
|
||||
self.extract_only || !self.formats.is_empty(),
|
||||
"Select at least one report."
|
||||
|
|
|
|||
|
|
@ -386,9 +386,35 @@ table.header("##,
|
|||
pub fn ontime(r: &Report) -> Value {
|
||||
let mut entries = serde_json::Map::new();
|
||||
let mut order = vec![];
|
||||
let mut flat_order = vec![];
|
||||
let mut elapsed = 0u64;
|
||||
let mut previous = false;
|
||||
for p in r.playbacks.iter().filter(|p| p.ontime_eligible) {
|
||||
for (index, p) in r
|
||||
.playbacks
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, p)| p.ontime_eligible)
|
||||
{
|
||||
let group = r
|
||||
.groups
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|(_, g)| index >= g.start && index < g.end);
|
||||
let parent = group.map(|(i, _)| {
|
||||
Uuid::new_v5(
|
||||
&Uuid::NAMESPACE_URL,
|
||||
format!("{}/group/{i}", r.presentation).as_bytes(),
|
||||
)
|
||||
.simple()
|
||||
.to_string()
|
||||
});
|
||||
if let (Some(id), Some((_, group))) = (&parent, group)
|
||||
&& !entries.contains_key(id)
|
||||
{
|
||||
entries.insert(id.clone(), json!({"id":id,"type":"group","title":group.title,"note":"","entries":[],"targetDuration":null,"colour":"#5744b5","custom":{},"revision":0,"timeStart":null,"timeEnd":null,"duration":0,"isFirstLinked":previous}));
|
||||
order.push(id.clone());
|
||||
flat_order.push(id.clone());
|
||||
}
|
||||
let seconds = p
|
||||
.video
|
||||
.duration_seconds
|
||||
|
|
@ -424,7 +450,16 @@ pub fn ontime(r: &Report) -> Value {
|
|||
"timeWarning":120000.min(duration/5),"timeDanger":60000.min(duration/10),
|
||||
"countToEnd":false,"flag":false,"custom":{},"triggers":[]
|
||||
}));
|
||||
order.push(id);
|
||||
if let Some(parent) = parent {
|
||||
entries.get_mut(&id).unwrap()["parent"] = json!(parent);
|
||||
entries.get_mut(&parent).unwrap()["entries"]
|
||||
.as_array_mut()
|
||||
.unwrap()
|
||||
.push(json!(id));
|
||||
} else {
|
||||
order.push(id.clone());
|
||||
}
|
||||
flat_order.push(id);
|
||||
if !skipped {
|
||||
elapsed += duration;
|
||||
previous = true;
|
||||
|
|
@ -444,7 +479,7 @@ pub fn ontime(r: &Report) -> Value {
|
|||
));
|
||||
}
|
||||
json!({"settings":{"version":"4.0.0"},"project":{"title":r.presentation,"description":description},
|
||||
"rundowns":{"default":{"id":"default","title":"Video timings","entries":entries,"order":order,"flatOrder":order,"revision":0}},
|
||||
"rundowns":{"default":{"id":"default","title":"Video timings","entries":entries,"order":order,"flatOrder":flat_order,"revision":0}},
|
||||
"customFields":{},"urlPresets":[],"viewSettings":{},
|
||||
"automation":{"enabledAutomations":false,"enabledOscIn":false,"triggers":[],"automations":{}}})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -309,10 +309,11 @@ fn gui_drop_and_recent_files() {
|
|||
fs::write(&path, b"").unwrap();
|
||||
assert_eq!(
|
||||
pptx_reporter::gui::accept_drop([path.clone()]).unwrap(),
|
||||
path
|
||||
vec![path.clone()]
|
||||
);
|
||||
assert!(pptx_reporter::gui::accept_drop([]).is_err());
|
||||
assert!(pptx_reporter::gui::accept_drop([path.clone(), path.clone()]).is_err());
|
||||
assert!(pptx_reporter::gui::accept_drop([path.clone(), path.clone()]).is_ok());
|
||||
assert!(pptx_reporter::gui::accept_drop([dir.path().to_path_buf()]).is_ok());
|
||||
assert!(pptx_reporter::gui::accept_drop([dir.path().join("test.pdf")]).is_err());
|
||||
let mut prefs = pptx_reporter::gui::Preferences::default();
|
||||
for i in 0..10 {
|
||||
|
|
@ -453,3 +454,224 @@ fn engine_probes_temporaries_generates_reports_and_handles_failure() {
|
|||
);
|
||||
assert!(engine::probe(&probe, Path::new("any"), &AtomicBool::new(true)).is_err());
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn fake_probe(dir: &Path) -> std::path::PathBuf {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let path = dir.join("ffprobe");
|
||||
fs::write(
|
||||
&path,
|
||||
"#!/bin/sh\nprintf '%s' '{\"format\":{\"duration\":\"10\"},\"streams\":[]}'\n",
|
||||
)
|
||||
.unwrap();
|
||||
fs::set_permissions(&path, fs::Permissions::from_mode(0o755)).unwrap();
|
||||
path
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn batch_pptx_groups_preserve_order_trims_and_unique_ids() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let a = dir.path().join("A.pptx");
|
||||
let b = dir.path().join("B.pptx");
|
||||
deck(
|
||||
&a,
|
||||
&[
|
||||
(
|
||||
picture("2", r#"<p14:trim st="1s" end="2s"/>"#),
|
||||
String::new(),
|
||||
),
|
||||
(picture("3", ""), timing("3", r#"repeatCount="indefinite""#)),
|
||||
],
|
||||
true,
|
||||
);
|
||||
deck(&b, &[(picture("2", ""), String::new())], true);
|
||||
let options = Options {
|
||||
source: b,
|
||||
additional_sources: vec![a],
|
||||
output: Some(dir.path().join("out")),
|
||||
ffprobe: Some(fake_probe(dir.path())),
|
||||
formats: vec!["json".into(), "ontime".into()],
|
||||
..Default::default()
|
||||
};
|
||||
let result = engine::run(&options, &AtomicBool::new(false), |_| {}).unwrap();
|
||||
let report = result.report.unwrap();
|
||||
assert_eq!(report.total_duration_seconds, 17.0);
|
||||
assert_eq!(report.groups.len(), 2);
|
||||
assert_eq!(report.groups[0].title, "A.pptx");
|
||||
assert_eq!(report.playbacks[2].settings.slide, Some(1));
|
||||
assert_eq!(
|
||||
report.playbacks[0].video.extracted_file.as_deref(),
|
||||
Some("../001/videos/shared.mp4")
|
||||
);
|
||||
let json = reports::ontime(&report);
|
||||
let rundown = &json["rundowns"]["default"];
|
||||
let order = rundown["order"].as_array().unwrap();
|
||||
let flat = rundown["flatOrder"].as_array().unwrap();
|
||||
assert_eq!(order.len(), 2);
|
||||
assert_eq!(flat.len(), 4); // Groups precede their supported cues; loop omitted.
|
||||
let entries = &rundown["entries"];
|
||||
assert_eq!(entries.as_object().unwrap().len(), 4);
|
||||
assert_eq!(entries[order[0].as_str().unwrap()]["title"], "A.pptx");
|
||||
assert_eq!(entries[flat[3].as_str().unwrap()]["timeStart"], 7000);
|
||||
assert_eq!(entries[flat[3].as_str().unwrap()]["linkStart"], true);
|
||||
assert_eq!(entries[flat[1].as_str().unwrap()]["parent"], order[0]);
|
||||
assert_eq!(entries[order[0].as_str().unwrap()]["entries"][0], flat[1]);
|
||||
assert_eq!(
|
||||
fs::read(result.output.join("001/videos/shared.mp4")).unwrap(),
|
||||
b"video"
|
||||
);
|
||||
assert_eq!(
|
||||
fs::read(result.output.join("002/videos/shared.mp4")).unwrap(),
|
||||
b"video"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn video_folder_and_parent_folder_use_filename_order() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path().join("show");
|
||||
let a = root.join("01 Intro");
|
||||
let b = root.join("02 Talk");
|
||||
fs::create_dir_all(&a).unwrap();
|
||||
fs::create_dir_all(&b).unwrap();
|
||||
fs::write(a.join("02.MP4"), b"second").unwrap();
|
||||
fs::write(a.join("01.mov"), b"first").unwrap();
|
||||
fs::write(a.join("notes.txt"), b"ignored").unwrap();
|
||||
fs::write(b.join("01.mov"), b"other").unwrap();
|
||||
let mut options = Options {
|
||||
source: a.clone(),
|
||||
timings_only: true,
|
||||
ffprobe: Some(fake_probe(dir.path())),
|
||||
formats: vec!["json".into(), "ontime".into()],
|
||||
..Default::default()
|
||||
};
|
||||
let report = engine::run(&options, &AtomicBool::new(false), |_| {})
|
||||
.unwrap()
|
||||
.report
|
||||
.unwrap();
|
||||
assert_eq!(report.playbacks[0].video.name, "01.mov");
|
||||
assert_eq!(report.playbacks[1].settings.slide, Some(2));
|
||||
assert_eq!(report.total_duration_seconds, 20.0);
|
||||
assert!(report.groups.is_empty());
|
||||
assert!(!options.output_dir().join("videos").exists());
|
||||
options.source = root.clone();
|
||||
let result = engine::run(&options, &AtomicBool::new(false), |_| {}).unwrap();
|
||||
let report = result.report.unwrap();
|
||||
assert_eq!(report.groups.len(), 2);
|
||||
assert_eq!(report.groups[1].title, "02 Talk");
|
||||
assert_eq!(report.total_duration_seconds, 30.0);
|
||||
assert_eq!(report.playbacks[2].settings.slide, Some(1));
|
||||
fs::write(root.join("mixed.mp4"), b"ambiguous").unwrap();
|
||||
assert!(
|
||||
engine::run(&options, &AtomicBool::new(false), |_| {})
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("mixes")
|
||||
);
|
||||
options.source = b;
|
||||
options.timings_only = false;
|
||||
options.extract_only = true;
|
||||
engine::run(&options, &AtomicBool::new(false), |_| {}).unwrap();
|
||||
let copied = options.output_dir().join("videos/01.mov");
|
||||
fs::write(&copied, b"preserved").unwrap();
|
||||
engine::run(&options, &AtomicBool::new(false), |_| {}).unwrap();
|
||||
assert_eq!(fs::read(&copied).unwrap(), b"preserved");
|
||||
options.overwrite = true;
|
||||
engine::run(&options, &AtomicBool::new(false), |_| {}).unwrap();
|
||||
assert_eq!(fs::read(&copied).unwrap(), b"other");
|
||||
assert!(engine::run(&options, &AtomicBool::new(true), |_| {}).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_discovery_empty_duplicates_and_pptx_directory() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mut options = Options {
|
||||
source: dir.path().to_owned(),
|
||||
..Default::default()
|
||||
};
|
||||
assert!(
|
||||
engine::run(&options, &AtomicBool::new(false), |_| {})
|
||||
.unwrap()
|
||||
.paths
|
||||
.is_empty()
|
||||
);
|
||||
let a = dir.path().join("a.pptx");
|
||||
let b = dir.path().join("b.PPTX");
|
||||
deck(&a, &[], false);
|
||||
deck(&b, &[], false);
|
||||
assert_eq!(
|
||||
pptx_reporter::inputs::discover(&options).unwrap(),
|
||||
vec![a.clone(), b.clone()]
|
||||
);
|
||||
options.additional_sources = vec![a.clone(), b.clone()];
|
||||
assert_eq!(
|
||||
pptx_reporter::inputs::discover(&options).unwrap(),
|
||||
vec![a, b]
|
||||
);
|
||||
assert!(
|
||||
engine::run(&options, &AtomicBool::new(false), |_| {})
|
||||
.unwrap()
|
||||
.paths
|
||||
.is_empty()
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn batch_failure_preserves_reports_and_cli_accepts_multiple_inputs() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let a = dir.path().join("A.pptx");
|
||||
let b = dir.path().join("B.pptx");
|
||||
deck(&a, &[(picture("2", ""), String::new())], true);
|
||||
fs::write(&b, b"invalid archive").unwrap();
|
||||
let output = dir.path().join("out");
|
||||
fs::create_dir_all(output.join("reports")).unwrap();
|
||||
let report = output.join("reports/timings.json");
|
||||
fs::write(&report, b"previous report").unwrap();
|
||||
let probe = fake_probe(dir.path());
|
||||
let cli = || {
|
||||
std::process::Command::new(env!("CARGO_BIN_EXE_pptx-reporter"))
|
||||
.arg(&b)
|
||||
.arg(&a)
|
||||
.args(["--timings-only", "--report", "json", "--ffprobe"])
|
||||
.arg(&probe)
|
||||
.arg("--output")
|
||||
.arg(&output)
|
||||
.output()
|
||||
.unwrap()
|
||||
};
|
||||
assert!(!cli().status.success());
|
||||
assert_eq!(fs::read(&report).unwrap(), b"previous report");
|
||||
deck(&b, &[(picture("2", ""), String::new())], true);
|
||||
assert!(cli().status.success());
|
||||
let result: Report = serde_json::from_slice(&fs::read(&report).unwrap()).unwrap();
|
||||
assert_eq!(result.groups[0].title, "A.pptx");
|
||||
assert_eq!(result.total_duration_seconds, 20.0);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn folder_refuses_media_symlinks_and_source_overwrite() {
|
||||
use std::os::unix::fs::symlink;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let source = dir.path().join("videos");
|
||||
fs::create_dir(&source).unwrap();
|
||||
let video = source.join("clip.mp4");
|
||||
fs::write(&video, b"source").unwrap();
|
||||
let mut options = Options {
|
||||
source,
|
||||
output: Some(dir.path().to_owned()),
|
||||
extract_only: true,
|
||||
overwrite: true,
|
||||
..Default::default()
|
||||
};
|
||||
assert!(engine::run(&options, &AtomicBool::new(false), |_| {}).is_err());
|
||||
let output = dir.path().join("out");
|
||||
fs::create_dir_all(output.join("videos")).unwrap();
|
||||
symlink(&video, output.join("videos/clip.mp4")).unwrap();
|
||||
options.output = Some(output);
|
||||
assert!(engine::run(&options, &AtomicBool::new(false), |_| {}).is_err());
|
||||
assert_eq!(fs::read(video).unwrap(), b"source");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,3 +135,10 @@ count, elapsed time, and the current extraction/probing/report step. It clears
|
|||
when finished, leaving report paths, the final summary, and warnings/errors.
|
||||
Long operations keep animating. Redirecting either output stream uses ordinary
|
||||
line logs instead. `NO_COLOR` disables colors; `TERM=dumb` also disables animation.
|
||||
|
||||
## Batch and folder inputs
|
||||
|
||||
Multiple PPTX files, folders of videos, and folders containing PPTX files or
|
||||
video subfolders use the same timing and report rules. Batches produce one
|
||||
combined export with named Ontime groups, ordered by filename. See
|
||||
[batch examples and folder rules](rust-reporter.md#batches-and-video-folders).
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ cargo run --locked --bin pptx-reporter -- presentation.pptx --timings-only --rep
|
|||
cargo run --locked --bin pptx-reporter -- presentation.pptx --extract-only
|
||||
```
|
||||
|
||||
Drop one PPTX into the window or choose a file. Check the save location, choose
|
||||
Drop PPTX files or a folder into the window, choose multiple presentations, or
|
||||
use **Choose folder…**. Check the save location, choose
|
||||
extraction/report mode, select formats, then use the purple action button.
|
||||
Reading & printing selects HTML, PDF and compact PDF; Defaults selects Markdown
|
||||
and Ontime. Advanced contains video replacement and FFprobe location controls.
|
||||
|
|
@ -42,3 +43,43 @@ Linux desktop builds need windowing/OpenGL libraries at runtime.
|
|||
|
||||
See [development](development.md) for source checks and [releases](releases.md)
|
||||
for Cross builds, packaging and dependency provenance.
|
||||
|
||||
## Batches and video folders
|
||||
|
||||
```sh
|
||||
# Multiple presentations: sorted by filename regardless of argument order
|
||||
pptx-reporter B.pptx A.pptx --timings-only --report ontime,json -o show-timings
|
||||
# All PPTX files and video subfolders directly inside a folder
|
||||
pptx-reporter ./show --timings-only --report ontime,json
|
||||
# A single folder of videos, treated as one presentation
|
||||
pptx-reporter ./clips --timings-only --report all
|
||||
```
|
||||
|
||||
Each run creates one combined set of reports. In Ontime, batches have one named
|
||||
group per presentation or video folder in a continuous rundown. Import
|
||||
`reports/timings.ontime.json` once, then set the first cue's start time. Groups
|
||||
with no eligible cues are omitted. The export follows Ontime’s
|
||||
[group import structure](https://github.com/cpvalente/ontime/blob/master/apps/server/src/api-data/rundown/rundown.parser.ts). Original local slide numbers are retained;
|
||||
source names prefix video names in combined reports. JSON includes `groups`
|
||||
with zero-based `start` (inclusive) and `end` (exclusive) playback indices.
|
||||
|
||||
A video folder uses each supported video's full duration as one slide, in
|
||||
case-sensitive filename order. Use zero-padded names (`01`, `02`, …) to control
|
||||
order; `10` sorts before `2`. Non-video files are ignored. Supported extensions:
|
||||
MP4, M4V, MOV, AVI, WMV, WebM, MPG, MPEG, MKV, ASF, 3GP and TS.
|
||||
PowerPoint trims still apply to PPTX inputs; plain video files have no PowerPoint
|
||||
trim or looping metadata. These are video timings, not slide-transition timings.
|
||||
|
||||
A parent folder includes its immediate PPTX files and immediate subfolders that
|
||||
contain videos. Deeper folders are not traversed. A folder mixing loose videos
|
||||
with presentations is rejected: select the inputs separately to make the order
|
||||
explicit. Duplicate input paths are processed once. Legacy `.ppt` files are not
|
||||
supported; save them as `.pptx` first.
|
||||
|
||||
The default output remains `<first-input>_videos/` (use `-o` to choose a batch
|
||||
location). Copied/extracted batch media lives in numbered `001/videos/`,
|
||||
`002/videos/`, … directories to avoid filename collisions. `--timings-only`
|
||||
reads source videos directly and extracts PPTX media only temporarily.
|
||||
`--extract-only` copies/extracts media without reports. Existing media is reused
|
||||
unless `--overwrite` is set; keep input selection/order stable when reusing a
|
||||
batch output folder, or choose a fresh output folder. Source files are preserved.
|
||||
|
|
|
|||
Loading…
Reference in New Issue