diff --git a/ox/file.py b/ox/file.py index 01f6856..ecddc0a 100644 --- a/ox/file.py +++ b/ox/file.py @@ -24,7 +24,7 @@ EXTENSIONS = { 'bmp', 'gif', 'jpeg', 'jpg', 'png', 'svg', 'webp' ], 'subtitle': [ - 'idx', 'srt', 'sub' + 'idx', 'srt', 'sub', 'vtt' ], 'video': [ '3gp', diff --git a/ox/vtt.py b/ox/vtt.py index 6dd7070..443a8ea 100644 --- a/ox/vtt.py +++ b/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)