Function rsubs_lib::ssa::parse

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

Parses the given String into a SRTFile

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

Examples found in repository?
examples/change_style_colors.rs (line 7)
6
7
8
9
10
11
12
13
14
15
16
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut ssa = rsubs_lib::ssa::parse("tests/fixtures/test.ass".to_string())
        .expect("Encountered Error parsing file");
    for style in ssa.styles.iter_mut() {
        if style.name == "Default" {
            style.firstcolor = ColorType::SSAColor(color::RED);
        }
    }
    ssa.to_file("result.ass")?;
    Ok(())
}
More examples
Hide additional examples
examples/convert_around.rs (line 15)
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();
}