-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove_overlaps and to_string #70
Conversation
In my remove_overlaps function, I made it automatically call clean_indexes() if a subtitle section gets entirely removed. I noticed in one of your comments you said that this could cause a problem for certain types of srt files. If this is the case, then I should alter my function to not automatically clean the indexes. EDIT: Done. |
Sorry but I don't think As for |
Although this PR didn't make it into the main repo, this helped me a lot with my project. Thank you very much @doakey3! @byroot you are right to reject this PR, even for me this was not the overlap removal method I needed. This changes start times of subtitles, but what actually made sense is to shorten lifetime of subtitles by changing the end time. |
That doesn't seem to be the case. >>> subtitles = pysrt.from_string('1\n00:00:00,000 --> 00:00:05,000\nTest')
>>> ''.join(subtitles)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sequence item 0: expected str instance, SubRipItem found This works though: >>> subtitles = pysrt.from_string('1\n00:00:00,000 --> 00:00:05,000\nTest\n\n2\n00:00:10,000 --> 00:00:15,000\nTest 2')
>>> '\n'.join(map(str, subtitles))
'1\n00:00:00,000 --> 00:00:05,000\nTest\n\n2\n00:00:10,000 --> 00:00:15,000\nTest 2\n' |
I've created 2 new functions. 1 for removing the overlap between subtitles and another for getting the srt format as a string (as opposed to saving to a file).