-
Notifications
You must be signed in to change notification settings - Fork 68
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
Encode error #12
Comments
Strange, I'm able to shift it without encoding error.
Can you paste the whole command you typed ? |
Well, a month without reply -> I close this issue. Feel free to reopen it if you still have a problem. |
Hi, sorry for the long responce srt shift 40s 33.srt python -V lsb_release -a |
Hum, very strange... so it always happen whatever the subtitle file ? And how did you installed it ? Beacause |
I've only tried on a few files, all russian, UTF8. |
Ok, I still can't reproduce but now I'm almost sure that it's a BOM issue... I will ask a friend on ubuntu to test that Did you tried the version released on PyPI ? |
I confirm it is a BOM issue. |
Pysrt is supposed to handle BOM correctly... And the file you gived to me is in cp1252, why did it have an utf-8 BOM ? |
I'm having the same issue |
I finally found the issue, it was because chardet returned My bad ... |
Is this fixed in 0.4.4? Because I still have this error |
I Think so. You still have the issue with this same file and pysrt 0.4.4 ? |
Oh shit ... confirmed, I'll fix that right now. |
Oh, I just forgot to release ... |
0.4.5 released with the fix. |
Thanks, that was fast :) |
I'm still having an error 😢
|
Of course |
Sample code to reproduce the error:
|
Oh ! it make sense now. If you open the file yourself pysrt do not strip the BOM. Anyway chardet is integrated inside pysrt now. Try something like: def is_valid_subtitle(path):
source_file = pysrt.SubRipFile._open_unicode_file(path)
try:
for _ in pysrt.SubRipFile.stream(source_file, error_handling=pysrt.SubRipFile.ERROR_RAISE):
pass
except pysrt.Error as e:
if e.args[0] < 50: # Error occurs within the 50 first lines
return False
# except UnicodeEncodeError: # Workaround for https://github.com/byroot/pysrt/issues/12
# pass
return True |
I can't run srt with this file http://dl.dropbox.com/u/1788271/Bones.S07E01.HDTVRip.srt
It is cp1251
I have the following error:
The text was updated successfully, but these errors were encountered: