lushan88a / google_trans_new

A free and unlimited python API for google translate.
MIT License
393 stars 170 forks source link

Bug on google_trans_new.py - google_translator.translate #55

Open Manu-Fraile opened 2 years ago

Manu-Fraile commented 2 years ago

Hi!

I've been experiencing the following error: File "/usr/lib/python3.8/json/__init__.py", line 357, in loads return _default_decoder.decode(s) File "/usr/lib/python3.8/json/decoder.py", line 340, in decode raise JSONDecodeError("Extra data", s, end) json.decoder.JSONDecodeError: Extra data: line 1 column 499 (char 498)

raised by: response = (decoded_line + ']') response = json.loads(response)

within the translate function of google_translator class.

I found a solution that works for me that is skipping the first line where the error occurs and adds a ']' and directly go with the decoded_line so that: `[...]

if "MkEWBc" in decoded_line: try: response = json.loads(decodedline) response = list(response) response = json.loads(response[0][2]) response = list(response) response = response_[1][0]

[...]`

Is this solution for the bug valid?

Many thanks!

WillDawnlll commented 1 year ago

not noticed this issue before i use this library... i used same way to fix exception finally is google response api changed ?