Skip to content
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

Deleting a subtitles line should also trigger a renumber #57

Open
Andbarz opened this issue Jan 9, 2015 · 3 comments
Open

Deleting a subtitles line should also trigger a renumber #57

Andbarz opened this issue Jan 9, 2015 · 3 comments

Comments

@Andbarz
Copy link

Andbarz commented Jan 9, 2015

I'm using your library to build a simple scripts which downloads subtitles from opensubtitles.org, removes all the unnecessary lines(synced by... and similar entries), saves the srt file and then encodes it into the video file with ffmpeg.
I've found that ffmpeg doesn't like srt files where there's a missing line, and it refuses to work with them.

This is what happens now:

1
00:00:22,712 --> 00:00:24,478
first line

2
00:00:25,000 --> 00:00:31,074
second line

3
00:00:57,413 --> 00:01:00,180
third line

when i run

del sub[1]

I get

1
00:00:22,712 --> 00:00:24,478
first line

3
00:00:57,413 --> 00:01:00,180
third line

Which is not valid according to ffmpeg. Instead I should get

1
00:00:22,712 --> 00:00:24,478
first line

2
00:00:57,413 --> 00:01:00,180
third line

Can you please make that when I close an srt file, pysrt automatically renumbers all the lines, so that there are no interruptions?

@byroot
Copy link
Owner

byroot commented Jan 9, 2015

I have to think about it. On one hand it would make perfect sense to do it automatically, but in the other end some subtitle have sometimes some kind of tags as indexes, so it would lose data.

I guess it could do it by default, and you could prevent it with close(clean_indexes=False).

That would require a minor version bump though.

@byroot
Copy link
Owner

byroot commented Jan 9, 2015

By the way until I issue a new version you can simply call clean_indexes() yourself:

def clean_indexes(self):
.

@Andbarz
Copy link
Author

Andbarz commented Jan 9, 2015

Sorry, I didn't find that function.
That was what I was really interested in, not automating it on close().
If you haven't time, just let things as they are now.

@Andbarz Andbarz closed this as completed Jan 9, 2015
@Andbarz Andbarz reopened this Jan 9, 2015
hashangayasri added a commit to hashangayasri/subscleaner that referenced this issue Sep 26, 2020
The function clean_indexes should be called to trigger a re-indexing according to byroot/pysrt#57 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants