firebfm / deepl-srt

Use Selenium to automate translation of a Chinese srt to English on Deepl website
13 stars 7 forks source link

Traceback error #1

Closed org0ne closed 3 years ago

org0ne commented 3 years ago

Hi, I am attempting to get this working on Win10 and am having issues

  1. Installed Python 64bit version: https://www.python.org/ftp/python/3.9.4/python-3.9.4-amd64.exe
  2. Added latest Chromedriver to "C:\Program Files (x86)\chromedriver.exe"
  3. pip install selenium
  4. pip install pyperclip (looks like you missed adding this dependency in the readme)
  5. Downloaded https://github.com/firebfm/deepl-srt/archive/refs/heads/main.zip
  6. Extracted zip file
  7. Entered CMD window and CD into "C:\Users\User\Downloads\deepl-srt-main\"
  8. Executed "python deeplv4.py"

Output: C:\Users\User\Downloads\deepl-srt-main>python deeplv4.py

DevTools listening on ws://127.0.0.1:57239/devtools/browser/4c0da8b8-da66-4dd6-8918-21f2d223c975 [10784:7252:0414/113246.120:ERROR:device_event_log_impl.cc(214)] [11:32:46.120] Bluetooth: bluetooth_adapter_winrt.cc:1072 Getting Default Adapter failed. enter path of srt folder c:\temp Traceback (most recent call last): File "c:\Users\org0ne\Downloads\deepl-srt-main\deeplv4.py", line 125, in <module> txtpath = remove_timeline(srt) File "c:\Users\org0ne\Downloads\deepl-srt-main\deeplv4.py", line 19, in remove_timeline contents = f.read() File "C:\Users\org0ne\AppData\Local\Programs\Python\Python39\lib\codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 34: invalid continuation byte

This is the specific file I was using RKI-111 CH.txt

firebfm commented 3 years ago

Your subtitle file has to end in .srt and be a UTF-8 encoding. Check in Subtitle Edit and save the encoding either as UTF-8 With BOM or UTF-8 Without BOM. Then my script will work.

org0ne commented 3 years ago

Cool thanks for the quick reply @firebfm. Changing the encoding fixed it. (my file was renamed to .txt so that github would allow uploading - .srt files are refused...)