46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
|
#!/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,
|
||
|
]))
|