Parse components of a subtitle file

srt_seconds(x)

srt_index(x)

srt_text(x, collapse = "\n")

Arguments

x

A character vector with the lines of an .srt file.

collapse

The character with which to separate subtitle lines.

Value

The parsed individual components of a subtitle: integer indexes, numeric times, and collapsed string subtitles.

Examples

# return individual components of each subtitle
x <- readLines(srt_example())
head(srt_seconds(x)[[1]])
#> [1]  85.210  88.422  90.674  93.802  96.889 100.350
head(srt_index(x))
#> [1] 1 2 3 4 5 6
head(srt_text(x))
#> [1] "I owe everything to George Bailey."  "Help him, dear Father."             
#> [3] "Joseph, Jesus and Mary,"             "help my friend Mr. Bailey."         
#> [5] "Help my son George tonight."         "He never thinks about himself, God."