1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Quickstart
==========
Parse an SRT to Python objects
------------------------------
.. code:: python
>>> import srt
>>> subtitle_generator = srt.parse('''\
... 1
... 00:31:37,894 --> 00:31:39,928
... OK, look, I think I have a plan here.
...
... 2
... 00:31:39,931 --> 00:31:41,931
... Using mainly spoons,
...
... 3
... 00:31:41,933 --> 00:31:43,435
... we dig a tunnel under the city and release it into the wild.
...
... ''')
>>> subtitles = list(subtitle_generator)
>>>
>>> subtitles[0].start
datetime.timedelta(0, 1897, 894000)
>>> subtitles[1].content
'Using mainly spoons,'
Compose an SRT from Python objects
----------------------------------
.. code:: python
>>> print(srt.compose(subtitles))
1
00:31:37,894 --> 00:31:39,928
OK, look, I think I have a plan here.
<BLANKLINE>
2
00:31:39,931 --> 00:31:41,931
Using mainly spoons,
<BLANKLINE>
3
00:31:41,933 --> 00:31:43,435
we dig a tunnel under the city and release it into the wild.
<BLANKLINE>
<BLANKLINE>
|