add vtt as subtitle extension

This commit is contained in:
j 2016-07-01 18:02:42 +02:00
parent 75d71707dd
commit d05acbfbbb
2 changed files with 12 additions and 2 deletions

View file

@ -24,7 +24,7 @@ EXTENSIONS = {
'bmp', 'gif', 'jpeg', 'jpg', 'png', 'svg', 'webp'
],
'subtitle': [
'idx', 'srt', 'sub'
'idx', 'srt', 'sub', 'vtt'
],
'video': [
'3gp',

View file

@ -3,7 +3,7 @@
import codecs
import ox
import srt
def _webvtt_timecode(t):
return ox.format_duration(t * 1000, years=False)
@ -30,3 +30,13 @@ def encode(data, webvtt=False):
)
return codecs.BOM_UTF8 + srt.encode('utf-8')
def load(filename, offset=0):
'''Parses vtt file
filename: path to an vtt file
offset (float, seconds): shift all in/out points by offset
Returns list with dicts that have in, out, value and id
'''
return srt.load(filename, offset)