A CLI PHP script that can do some useful operations on WebVTT files (currently: extracting all the subtitles, adding indexed identifiers)
- PHP 100%
| README.md | ||
| sample.vtt | ||
| webvttu | ||
[[[ SYNOPSIS ]]]
webvttu [options] <action> <file[s]>
[[[ DESCRIPTION ]]]
This is webvttu v0.2.1, a CLI PHP script that can do some useful
operations on WebVTT files. WebVTT (Web Video Text Tracks, vtt extension)
is a file format for video subtitles (see https://www.w3.org/TR/webvtt1).
[[[ ACTIONS ]]]
convert
The script will save a new version of each vtt file you pass to it into
«[original file path].txt». Each saved file will contain only the subtitles,
with each sentence on a line, «<b>...</b>», «<i>...</i>» and «<u>...</u>» HTML
tags converted to «*», «/» and «_», «<v [name]>» tags converted to «name: »,
and all the other tags removed (see also the «-n» and «-N» options
descriptions below).
index
The script will save a new version of each vtt file you pass to it into a
file in the same directory as the original, with the same filename followed by
«-indexed», and the same extension. In each saved file, every cue will be
prepended by an identifier (that will be substituted to the existing one, if
present) which will be a progressive number starting from 1 and increasing by
1 according to the sequence of cues inside the original file.
[[[ OPTIONS ]]]
-n / --no-format
Don’t convert HTML bold, italic and underline opening and ending tags to
«*», «/» and «_». Useful only in «convert» mode.
-N / --no-newlines
Instead of adding a new-line character, add a space character after lines
ending with «.», «?», «!». Useful only in «convert» mode.
--
Treat every possible subsequent argument as non-options. Useful only in case
one or more of the files you want to process have the same name as one of the
options.
-h / --help
Show this help text and exit.
[[[ EXIT VALUES ]]]
0: regular run
1: some error occurred
[[[ DISCLAIMER AND LICENSE ]]]
This program comes with ABSOLUTELY NO WARRANTY; for details see the source.
This is free software, and you are welcome to redistribute it under certain
conditions; see <http://www.gnu.org/licenses/> for details.