byroot / pysrt

Python parser for SubRip (srt) files
GNU General Public License v3.0
446 stars 67 forks source link

call clean_indexes after opening a file? #53

Closed felagund closed 10 years ago

felagund commented 10 years ago

The following is a perfectly valid SRT file (at least anything that handles them will open it just fine), let's call it subs.srt:

3
00:08:17,317 --> 00:08:19,328
It is life or death, James.

The following happens

a = pysrt.open('subs.srt')
a[0].index
>>>> 3
a.clean_indexes()
a[0].index
>>>> 1

Should not clean_indexes() be called after opening the subtitles by default? There is also the issue that index after calling clean_indexes() starts at 1 and python lists start at 0, but I do not think it would be wise to do anything about it.

byroot commented 10 years ago

Indexes usually mean nothing, most players don't care about them, and they can be in totally random orders, or have duplicates, nobody will say anything.

I have no idea what was the original intent for it...

But it's still data, so it shouldn't change implicitly. I want pysrt.open(path).write() not to change the file, except duplicate blank lines maybe.

So no, no automatic call to clean_indexes().