62 lines
3.0 KiB
Python
62 lines
3.0 KiB
Python
"""Create an Ontime 4 project from a video timing report."""
|
|
import math
|
|
from uuid import NAMESPACE_URL, uuid5
|
|
|
|
|
|
def ontime_project(data):
|
|
"""Expand shared videos into slide cues; retain uncertain cues as skipped."""
|
|
occurrences = [
|
|
(slide, video)
|
|
for video in data['videos']
|
|
for slide in (video['slides'] or [None])
|
|
]
|
|
occurrences.sort(key=lambda item: (item[0] if item[0] is not None else math.inf,
|
|
item[1]['name'], item[1]['archive_path']))
|
|
entries = {}
|
|
elapsed = 0
|
|
has_previous = False
|
|
for slide, video in occurrences:
|
|
seconds = video['duration_seconds']
|
|
valid = seconds is not None and math.isfinite(seconds) and 0 <= seconds <= 86399
|
|
duration = round(seconds * 1000) if valid else 0
|
|
skipped = not valid or slide is None
|
|
cue = f'Slide {slide}' if slide is not None else 'Unreferenced'
|
|
note = f'{data["presentation"]} — {video["archive_path"]}. Original media duration; trimming and looping are not applied.'
|
|
if not valid:
|
|
note += ' Duration unknown or outside Ontime limits; review before enabling.'
|
|
if slide is None:
|
|
note += ' No slide reference; review before enabling.'
|
|
event_id = uuid5(NAMESPACE_URL, f'{data["presentation"]}/{video["archive_path"]}#{slide}').hex
|
|
entries[event_id] = {
|
|
'id': event_id, 'type': 'event', 'cue': cue, 'title': video['name'],
|
|
'note': note, 'duration': duration, 'timeStart': elapsed % 86400000,
|
|
'timeEnd': (elapsed + duration) % 86400000,
|
|
'timeStrategy': 'lock-duration', 'linkStart': has_previous,
|
|
'timerType': 'count-down', 'endAction': 'none',
|
|
'skip': skipped, 'colour': '#b7791f' if skipped else '#5744b5',
|
|
'timeWarning': min(120000, duration // 5),
|
|
'timeDanger': min(60000, duration // 10),
|
|
'countToEnd': False, 'flag': False, 'custom': {}, 'triggers': [],
|
|
}
|
|
if not skipped:
|
|
elapsed += duration
|
|
has_previous = True
|
|
description = (
|
|
'Video cues in slide order. Shared videos appear once per referenced slide. '
|
|
'Times start at midnight and are linked; set the first cue to your show start. '
|
|
'Unknown durations and unreferenced media are skipped pending review.'
|
|
)
|
|
if data['external_media_slides']:
|
|
description += ' External media was not exported (slides: ' + ', '.join(map(str, data['external_media_slides'])) + ').'
|
|
return {
|
|
'settings': {'version': '4.0.0'},
|
|
'project': {'title': data['presentation'], 'description': description},
|
|
'rundowns': {'default': {
|
|
'id': 'default', 'title': 'Video timings', 'entries': entries,
|
|
'order': list(entries), 'flatOrder': list(entries), 'revision': 0,
|
|
}},
|
|
'customFields': {}, 'urlPresets': [], 'viewSettings': {},
|
|
'automation': {'enabledAutomations': False, 'enabledOscIn': False,
|
|
'triggers': [], 'automations': {}},
|
|
}
|