Function rsubs_lib::vtt::parse

source ·
pub fn parse(path_or_content: String) -> Result<VTTFile, Error>
Expand description

Parses the given String into a VTTFile

The string may represent either the path to a file or the file content itself.

Examples found in repository?
examples/convert_around.rs (line 12)
7
8
9
10
11
12
13
14
15
16
17
18
19
fn main() {
    vtt::VTTFile::from(srt::SRTFile::from_str("./tests/fixtures/test.srt").unwrap()) // Can read either a file or a string
        // converts file to WEBVTT
        .to_file("./tests/fixtures/ex_test_1.vtt") // Writes the converted subtitle to a file
        .unwrap();
    ssa::SSAFile::from(vtt::parse("./tests/fixtures/test.vtt".to_string()).unwrap()) // converts file to SSA/ASS
        .to_file("./tests/fixtures/ex_test_1.ass")
        .unwrap();
    srt::SRTFile::from(ssa::parse("./tests/fixtures/test.ass".to_string()).unwrap())
        // converts file to SRT
        .to_file("./tests/fixtures/ex_test_1.srt")
        .unwrap();
}