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

Example usage ReadFromSRT in the README is incorrect #86

Closed
mikzorz opened this issue May 18, 2023 · 4 comments
Closed

Example usage ReadFromSRT in the README is incorrect #86

mikzorz opened this issue May 18, 2023 · 4 comments

Comments

@mikzorz
Copy link

mikzorz commented May 18, 2023

s2, _ := astisub.ReadFromSRT(bytes.NewReader([]byte("00:01:00.000 --> 00:02:00.000\nCredits")))

This lines produces 2 errors.
The first is fixed by replacing the dots in the timestamps with commas.
s2, _ := astisub.ReadFromSRT(bytes.NewReader([]byte("00:01:00,000 --> 00:02:00,000\nCredits")))

The second is because the input string begins with the timestamp.
Starting at line 53 in str.go:

https://github.com/asticode/go-astisub/blob/b6b18718ddb6ee0da08772d8ab310c9c3d2d0459/srt.go#L52C3-L58

Appending a line to the input []byte avoids the error.

s2, _ := astisub.ReadFromSRT(bytes.NewReader([]byte("1\n00:01:00,000 --> 00:02:00,000\nCredits")))

@asticode
Copy link
Owner

You're right regarding the missing first index. I've fixed on master. Comma or dot don't matter for srt times though.

@mikzorz
Copy link
Author

mikzorz commented May 19, 2023

If I use dots, it returns an error:
astisub: line 2: parsing srt duration 00:01:00.000 failed: astisub: atoi of 00.000 failed: strconv.Atoi: parsing "00.000": invalid syntax

@asticode
Copy link
Owner

Ha I forgot to make a tag with the latest changes. Could you fetch v0.24.0 and make sure it's working properly?

@mikzorz
Copy link
Author

mikzorz commented May 19, 2023

Yep, works as expected! Just needed to upgrade my version. Thank you very much!

@mikzorz mikzorz closed this as completed May 19, 2023
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