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

Parser is failed to parse some files #11

Closed
shafqat-muneer opened this issue Oct 2, 2015 · 11 comments
Closed

Parser is failed to parse some files #11

shafqat-muneer opened this issue Oct 2, 2015 · 11 comments
Labels

Comments

@shafqat-muneer
Copy link
Contributor

Hi @mhergon ,

I am facing some issue during parsing two files.
https://dl.dropboxusercontent.com/u/32254461/Subtitles/English.srt [Successfully Parsing]
https://dl.dropboxusercontent.com/u/32254461/Subtitles/Espanish.srt [Failed to Parse]

Both files structure is same. You can view it by tapping on links.

Code is breaking on these lines:
NSString *textString;
[scanner scanUpToString:@"\r\n\r\n" intoString:&textString];
textString = [textString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

"textString" is returning whole file data at once in case of some files. These are just sample files; Its also breaking for many English and Espanish files.

Please look into the issue; If i am doing something wrong then please let me know.

Thanks,
Shafqat

@mhergon
Copy link
Owner

mhergon commented Oct 2, 2015

Please, remove "WEBVTT FILE" and the other blank lines at the top and try again

@shafqat-muneer
Copy link
Contributor Author

Still not working after removing "WEBVTT FILE" and the other blank lines at the top;
Actually with "WEBVTT FILE" entry, its working for some files as well.

@mhergon mhergon added the bug label Oct 2, 2015
@kudeiro
Copy link

kudeiro commented Oct 4, 2015

i also had problems with an srt in Spanish, i solved it changing NSUTF8StringEncoding to NSASCIIStringEncoding

@shafqat-muneer
Copy link
Contributor Author

I have also tried it by changing NSUTF8StringEncoding to NSASCIIStringEncoding. Its still not working; Can you please try it by using above Espanish file?

There may be chances, something is different in Espanish file format but unable to differentiate it.

Thanks

@shafqat-muneer
Copy link
Contributor Author

Hi,

I have fixed this issue at my side.

Investigated Issue:
Hidden Characters Sequence in English SRT Files: \r\n\r\n
Hidden Characters Sequence in Spanish SRT Files: \n\n\n

So, we need to handled both of them. It seems to be working perfectly after syncing both of these flavours.

If you wish, i can generate pull request for this changes. For this, i need some permissions over github; Otherwise, you can add following line in MPMoviePlayerController+Subtitles.m after Line#56.

subtitleString = [subtitleString stringByReplacingOccurrencesOfString:@"\n\n\n" withString:@"\r\n\r\n"];

Thanks,
Shafqat

@mhergon
Copy link
Owner

mhergon commented Oct 8, 2015

Send me a pull request

Thanks!

@mhergon mhergon closed this as completed Oct 8, 2015
@shafqat-muneer
Copy link
Contributor Author

Pull Request: #12

@mhergon
Copy link
Owner

mhergon commented Oct 8, 2015

@shafqat-muneer
Please, check merged files

@mhergon mhergon reopened this Oct 8, 2015
@shafqat-muneer
Copy link
Contributor Author

Yes; Merged perfectly. Thanks.
I have also create pull request #13 for Multi language SRT support. Please have a look.

@mhergon
Copy link
Owner

mhergon commented Oct 8, 2015

Please, check merged
Thanks!

@mhergon mhergon closed this as completed Oct 8, 2015
@shafqat-muneer
Copy link
Contributor Author

Working perfectly.
Thanks,
Shafqat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants