Skip to content

undertext

PyPI-Version


Library README scraped 2024-04-03

undertext

library to load, edit and save different formats of subtitles

PyPI - Version

NOTE

This Project is under development. Come back soon for updates

Installation

shell
pip3 install undertext

File Formats

extnamereadwrite
.assAdvanced SubStation Alpha
.sbvSubViewer
.srtSubRip
.ssaSub Station Alpha
.subMicroDVD
.vttWebVTT

Listed formats that are currently unsupported may be added at a later version

Examples

python
import undertext

captions = undertext.loads("example.en.srt")
undertext.dumps(captions, "example.en.vtt")
python
import undertext

captions = [
    undertext.Caption(start=0, end=10, text="Hello"),
    undertext.Caption(start=10, end=20, text="World"),
]
undertext.dumps(captions, "out.srt")

CLI

NOTE

During the installation the undertext command should be installed and then available. If this didn't work you can invoke it with python3 -m undertext instead.

shell
$ cat example.vtt
WEBVTT

00:00:00.000 --> 00:00:01.000
hello world 0

00:00:02.000 --> 00:00:03.000
hello world 2

00:00:04.000 --> 00:00:05.000
hello world 4

00:00:06.000 --> 00:00:07.000
hello world 6

00:00:08.000 --> 00:00:09.000
hello world 8
$ undertext read example.vtt
<00:00:00.000 -> 00:00:01.000> 'hello world 0'
<00:00:02.000 -> 00:00:03.000> 'hello world 2'
<00:00:04.000 -> 00:00:05.000> 'hello world 4'
<00:00:06.000 -> 00:00:07.000> 'hello world 6'
<00:00:08.000 -> 00:00:09.000> 'hello world 8'
shell
$ undertext convert example.vtt output.srt 
$ cat output.srt
1
00:00:00,000 --> 00:00:01,000
hello world 0

2
00:00:02,000 --> 00:00:03,000
hello world 2

3
00:00:04,000 --> 00:00:05,000
hello world 4

4
00:00:06,000 --> 00:00:07,000
hello world 6

5
00:00:08,000 --> 00:00:09,000
hello world 8