jansenicus / vtt-to-srt.py

python script to convert all vtt files in a directory and all of its subdirectories to srt subtitle format
61 stars 33 forks source link

Files with utf8 encoding #2

Closed bezik46 closed 5 years ago

bezik46 commented 6 years ago

line 62 needs to be:

f = open(strNamaFile, "r", errors='ignore')

Taken from https://stackoverflow.com/questions/9233027/unicodedecodeerror-charmap-codec-cant-decode-byte-x-in-position-y-character

otherwise it fails with:

Traceback (most recent call last): File "vtt-to-srt.py", line 127, in <module> main() File "vtt-to-srt.py", line 125, in main walktree(TopMostPath, convertVTTtoSRT) File "vtt-to-srt.py", line 104, in walktree callback(pathname) File "vtt-to-srt.py", line 117, in convertVTTtoSRT vtt_to_srt(file) File "vtt-to-srt.py", line 82, in vtt_to_srt fileCreate(strNamaFile, strData) File "vtt-to-srt.py", line 46, in fileCreate f.writelines(str(strData)) File "C:\Program Files\Python35\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\ufeff' in position 0: character maps to <undefined>