Vttyl
A dead simple vtt parser in Elixir.
Installation
To install Vttyl, add it to your mix.exs
file.
def deps do
[
{:vttyl, "~> 0.3.0"}
]
end
Then, run $ mix deps.get
.
Usage
Decoding
Vttyl has two basic ways to use it.
String Parsing
iex> vtt = """
WEBVTT
1
00:00:15.450 --> 00:00:17.609
Hello world!
"""
...> Vttyl.parse(vtt) |> Enum.into([])
[%Vttyl.Part{end: 17609, part: 1, start: 15450, text: "Hello world!"}]
Stream Parsing
iex> "same_text.vtt" |> File.stream!([], 2048) |> Vttyl.parse_stream() |> Enum.into([])
[%Vttyl.Part{end: 17609, part: 1, start: 15450, text: "Hello world!"}]
Encoding
Vttyl also supports encoding parts.
iex> parts = [%Vttyl.Part{end: 17609, part: 1, start: 15450, text: "Hello world!"}]
...> Vttyle.encode(parts)
"""
WEBVTT
1
00:00:15.450 --> 00:00:17.609
Hello world!
"""
License
Vttyl is Copyright © 2019 Grain Intelligence, Inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.
About Grain
Vttyl is maintained and funded by Grain Intelligence, Inc. The names and logos for Grain are trademarks of Grain Intelligence, Inc.
For more information, see the documentation.