also import vtt

This commit is contained in:
j 2016-07-01 18:02:19 +02:00
parent e67f084673
commit 41101d9b34
2 changed files with 6 additions and 2 deletions

View file

@ -899,11 +899,15 @@ class Client(object):
if layer not in layers:
print("invalid layer name, choices are: ", ', '.join(layers))
sys.exit(1)
if filename.endswith('.vtt'):
load = ox.vtt.load
else:
load = ox.srt.load
annotations = [{
'in': s['in'],
'out': s['out'],
'value': s['value'].replace('\n', '<br>\n') if layer == 'subtitles' else s['value'],
} for s in ox.srt.load(filename)]
} for s in load(filename)]
r = self.api.addAnnotations({
'item': item,
'layer': layer,

View file

@ -42,7 +42,7 @@ def avinfo(filename, cached=True):
dar = AspectRatio(info['video'][0]['width'], info['video'][0]['height'])
info['video'][0]['display_aspect_ratio'] = dar.ratio
del info['path']
if os.path.splitext(filename)[-1] in ('.srt', '.sub', '.idx', '.rar') and 'error' in info:
if os.path.splitext(filename)[-1] in ('.vtt', '.srt', '.sub', '.idx', '.rar') and 'error' in info:
del info['error']
if 'code' in info and info['code'] == 'badfile':
del info['code']