Show trim details and loop pills in timing reports
This commit is contained in:
parent
6d6cb3b907
commit
abd850a217
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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'<span class="pill muted">{row[5]}</span>'
|
||||
if video['extracted_file']:
|
||||
row[2] = f'<a href="{html.escape(quote(video["extracted_file"]))}">{row[2]}</a>'
|
||||
if video['playback_status'] == 'looping':
|
||||
row[1] = '—'
|
||||
row[2] += ' <span class="pill warning loop">Looping</span>'
|
||||
detail = trim_detail(video)
|
||||
if detail:
|
||||
row[2] += f'<small class="trim">{html.escape(detail)}</small>'
|
||||
table_rows.append('<tr>' + ''.join(f'<td>{value}</td>' for value in row) + '</tr>')
|
||||
return (
|
||||
'<!doctype html>\n<html lang="en"><head><meta charset="utf-8">\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}}</style></head><body>\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)']
|
||||
|
|
|
|||
Loading…
Reference in New Issue