dont fail if files dont have all format keys

This commit is contained in:
j 2015-01-22 15:31:36 +05:30
parent e4c51f0598
commit dc6f25aac1

View file

@ -226,9 +226,13 @@ def ffprobe(filename):
info['error'] = 'badfile' info['error'] = 'badfile'
else: else:
for key in ('duration', 'size', 'bit_rate'): for key in ('duration', 'size', 'bit_rate'):
info[{ if key in ffinfo['format']:
'bit_rate': 'bitrate' info[{
}.get(key, key)] = fix_value(key, ffinfo['format'][key]) '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['audio'] = []
info['video'] = [] info['video'] = []
info['metadata'] = ffinfo['format'].get('tags', {}) info['metadata'] = ffinfo['format'].get('tags', {})