pythonsrt

How to extract Time from a SRT File?


I'am a newbie in python and i want help in extracting the Start and End time from a SRT File of a movie for my project.

Example:

1

00:00:39,330 --> 00:00:41,958

Things are never gonna be
the same now.

2

00:00:42,125 --> 00:00:44,169

I mean, look at this.

3

00:00:44,336 --> 00:00:46,379

You got aliens.

I want to Extract the Start time(00:00:39) and End time(00:00:41) and the text(Things are never gonna be the same now.) Thanks in Advance!


Solution

  • I would recommend using an existing library, such as https://pypi.org/project/srt/ for that purpose.