From dc6f25aac14aaaa8ab897816278baa01a42c55f0 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 22 Jan 2015 15:31:36 +0530 Subject: [PATCH] dont fail if files dont have all format keys --- ox/file.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ox/file.py b/ox/file.py index 26d16a9..775c13b 100644 --- a/ox/file.py +++ b/ox/file.py @@ -226,9 +226,13 @@ def ffprobe(filename): info['error'] = 'badfile' else: for key in ('duration', 'size', 'bit_rate'): - info[{ - 'bit_rate': 'bitrate' - }.get(key, key)] = fix_value(key, ffinfo['format'][key]) + if key in ffinfo['format']: + info[{ + 'bit_rate': 'bitrate' + }.get(key, key)] = fix_value(key, ffinfo['format'][key]) + if not 'size' in info: + info['size'] = os.stat(filename).st_size + print('no size in info', filename, ffinfo) info['audio'] = [] info['video'] = [] info['metadata'] = ffinfo['format'].get('tags', {})