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

Avoid crashes for files with position information following the timestamp #3

Merged
merged 2 commits into from
Jun 4, 2022

Conversation

lucas-deangelis
Copy link
Contributor

Hi,
First of all, thank you for this library, I've used it to create a small tool to extract text from subtitles and it worked great. However, I've had a few crashes on files with position information following the timestamp. Here's a minimal example:

1
00:00:07,001 --> 00:00:09,015 position:50,00%,middle align:middle size:80,00% line:84,67%
This is a subtitle text

I've fixed this by modifying a bit the parsing code of the timestamp line of Subtitle.parse to be able to handle that, and added a test case. I've also edited the documentation to reflect the changes.

@GavalasDev
Copy link
Owner

Hello and thanks for the very well-thought-out pull request!

When making this library I made the (very naive) assumption that all .srt subtitle files follow a very standard and simple structure. In hindsight, bugs like this were bound to eventually appear, and I'm thankful that people like you are willing to invest their time and effort to squash them.

Greater thought should probably be put into how we handle these "weirder" cases in the future (e.g. adding a new field in Subtitle structs to contain the position information) although your temporary fix is perfect for now.

Thanks again for the great pull request, I'll be merging it soon.

@GavalasDev GavalasDev merged commit 6150e7c into GavalasDev:master Jun 4, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants