From abd850a2172c0671f3deeea05f2c41f615007de8 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Tue, 20 Oct 2026 11:20:30 +0200 Subject: [PATCH] Show trim details and loop pills in timing reports --- docs/pptx-videos.md | 8 +++++++- tools/pptx_videos.py | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/docs/pptx-videos.md b/docs/pptx-videos.md index 4a4cb43..3d7f4f8 100644 --- a/docs/pptx-videos.md +++ b/docs/pptx-videos.md @@ -49,7 +49,10 @@ python3 tools/pptx_videos.py presentation.pptx --timings-only --report pdf-dense This creates `timings-dense.pdf` and its editable `timings-dense.typ` source. It has a discreet title containing the presentation name and no summary cards. -Slide numbers and media names are plain text; only durations use pills. +Slide numbers and media names are plain text; durations and loop markers use pills. +Trimmed videos show a discreet line under the media name with the amounts removed +from the start and end. Looping videos carry an amber **Looping** pill next to +their name and a dash instead of a finite duration. The duration caveat stays in a small footnote. Use `--report pdf,pdf-dense` to produce both layouts. @@ -65,6 +68,9 @@ durations. Media size and embedded-video counts still count each file once. **Duration** is the single-play duration after PowerPoint's start and end trims. The full reports also show **Original** duration and **Playback** status. +HTML and both PDF layouts show start/end trim details below the media name and +an amber **Looping** pill for repeated playback. Markdown and TXT include the +trim details in the Playback column. `pdf-dense` retains its three columns; its duration pill shows a status when there is no usable duration. diff --git a/tools/pptx_videos.py b/tools/pptx_videos.py index e44b47e..5e9e076 100644 --- a/tools/pptx_videos.py +++ b/tools/pptx_videos.py @@ -233,6 +233,28 @@ def typst_string(value): ) + '"' +def trim_detail(video): + start = video.get('trim_start_seconds', 0) + end = video.get('trim_end_seconds', 0) + if not (start or end): + return '' + return f'Trim removed · start {time_fmt(start)} · end {time_fmt(end)}' + + +def typst_media(video, dense=False): + """Keep playback annotations with the media, without adding table columns.""" + detail = trim_detail(video) + if not detail and video['playback_status'] != 'looping': + return typst_string(video['name']) + content = '#' + typst_string(video['name']) + if video['playback_status'] == 'looping': + colors = '"#fff0ce", "#805300"' if dense else 'bg: "#fff0ce", fg: "#805300"' + content += f' #pill("Looping", {colors})' + if detail: + content += '\n#par(leading: 2pt, text(size: 7pt, fill: rgb("#626b80"), ' + typst_string(detail) + '))' + return '[' + content + ']' + + def render_report(data, format): if format == 'ontime': return json.dumps(ontime_project(data), ensure_ascii=False, indent=2, allow_nan=False) + '\n' @@ -265,6 +287,9 @@ def render_report(data, format): return json.dumps(data, ensure_ascii=False, indent=2, allow_nan=False) + '\n' if format in ('md', 'txt'): for row, video in zip(cells, report_rows): + detail = trim_detail(video) + if detail: + row[7] += '; ' + detail row[:] = [esc(value) if format == 'md' else value.replace('\n', ' ') for value in row] if format == 'md' and video['extracted_file']: row[2] = f'[{row[2]}]({quote(video["extracted_file"])})' @@ -283,6 +308,12 @@ def render_report(data, format): row[5] = f'{row[5]}' if video['extracted_file']: row[2] = f'{row[2]}' + if video['playback_status'] == 'looping': + row[1] = '—' + row[2] += ' Looping' + detail = trim_detail(video) + if detail: + row[2] += f'{html.escape(detail)}' table_rows.append('' + ''.join(f'{value}' for value in row) + '') return ( '\n\n' @@ -310,6 +341,7 @@ def render_report(data, format): '.pill{display:inline-block;border-radius:999px;padding:3px 10px;font-size:12px;font-weight:600;margin:2px 0}' '.slide{background:#eeeafd;color:#49359b}.duration{background:#e3f4ee;color:#176349}' '.warning{background:#fff0ce;color:#805300}.muted{background:#edf0f6;color:#566176}' + '.trim{display:block;color:#626b80;font-size:11px;font-weight:400;margin-top:4px}.loop{margin-left:6px}' 'footer{color:#626b80;font-size:12px;margin-top:24px;border-left:3px solid #dcd5f6;padding-left:16px}' 'footer p{margin:5px 0}@media(max-width:760px){body{margin:24px auto;padding:0 16px}.metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.metric strong{font-size:18px}}' '@media print{html{background:white}body{margin:0;padding:0;max-width:none}.table{overflow:visible;box-shadow:none}.metrics,.metric,tr{break-inside:avoid}thead{display:table-header-group}*{print-color-adjust:exact}}\n' @@ -343,7 +375,8 @@ def render_report(data, format): ] for row, video in zip(cells, report_rows): bg, fg = ('#e3f4ee', '#176349') if video['duration_seconds'] is not None else ('#fff0ce', '#805300') - lines.append(f' {typst_string(row[0])}, {typst_string(row[2])}, pill({typst_string(row[1])}, "{bg}", "{fg}"),') + duration = '"—"' if video['playback_status'] == 'looping' else f'pill({typst_string(row[1])}, "{bg}", "{fg}")' + lines.append(f' {typst_string(row[0])}, {typst_media(video, dense=True)}, {duration},') lines += [')', '#v(6pt)'] lines += ['#par(text(size: 7pt, fill: rgb("#626b80"), ' + typst_string(note) + '))' for note in notes] return '\n'.join(lines) + '\n' @@ -386,6 +419,9 @@ def render_report(data, format): values[0] = '[' + ' '.join('#pill(' + typst_string(str(slide)) + ')' for slide in video['slides']) + ']' if video['slides'] else 'text(size: 8pt, fill: rgb("#626b80"), "Unreferenced")' bg, fg = ('#e3f4ee', '#176349') if video['duration_seconds'] is not None else ('#fff0ce', '#805300') values[1] = f'pill({values[1]}, bg: "{bg}", fg: "{fg}")' + if video['playback_status'] == 'looping': + values[1] = '"—"' + values[2] = typst_media(video) values[5] = f'pill({values[5]}, bg: "#edf0f6", fg: "#566176")' lines.append(' ' + ', '.join(values) + ',') lines += [')', '#v(10pt)']