From 5ddc19a267dcefbb52e33b043ddda45357d21a2d Mon Sep 17 00:00:00 2001 From: j Date: Wed, 5 Dec 2018 12:30:02 +0100 Subject: [PATCH] logsheet --- make_logsheet.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 make_logsheet.py diff --git a/make_logsheet.py b/make_logsheet.py new file mode 100644 index 0000000..ab2ea7c --- /dev/null +++ b/make_logsheet.py @@ -0,0 +1,45 @@ +#!/usr/bin/python3 +import json +import sys + +def format_duration(seconds): + seconds = float(seconds) + d = int(seconds / 86400) + h = int(seconds % 86400 / 3600) + m = int(seconds % 3600 / 60) + s = float(seconds % 60) + + durations = [] + if h: + durations.append('%sh' % h) + if m: + durations.append('%sm' % m) + if s: + durations.append('%ss' % int(s)) + r = ' '.join(durations) + return r + ((10-len(r)) * ' ') + + +presets = json.load(open(sys.argv[1])) +sequence = json.load(open(sys.argv[2])) + + +padding = max([len(p['name']) for p in presets]) + 5 + +position = 0 +for i, clip in enumerate(sequence): + preset = [p for p in presets if p['id'] == clip['preset']][0] + + if clip.get('duration'): + position += clip.get('duration', 0) + d = format_duration(clip['duration']) + else: + d = '... ' + + print('\t'.join([ + '%02d' % preset['id'] + ': ' + preset['name'] + ((padding-len(preset['name'])) * ' '), + format_duration(position), + 'Speed: ' + str(clip.get('speed', 0)), + 'Sleep: ' + str(clip.get('sleep', 0)), + d, + ]))