add vtt as subtitle extension
This commit is contained in:
parent
75d71707dd
commit
d05acbfbbb
2 changed files with 12 additions and 2 deletions
|
@ -24,7 +24,7 @@ EXTENSIONS = {
|
|||
'bmp', 'gif', 'jpeg', 'jpg', 'png', 'svg', 'webp'
|
||||
],
|
||||
'subtitle': [
|
||||
'idx', 'srt', 'sub'
|
||||
'idx', 'srt', 'sub', 'vtt'
|
||||
],
|
||||
'video': [
|
||||
'3gp',
|
||||
|
|
12
ox/vtt.py
12
ox/vtt.py
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue