Animenosekai / translate

A module grouping multiple translation APIs
GNU Affero General Public License v3.0
499 stars 59 forks source link

Bing Translator throwing error code 205 #72

Closed GymnopedieNo4 closed 1 year ago

GymnopedieNo4 commented 1 year ago

Made a simple script to reproduce the error using 2 different IP addresses but same country.

from translatepy.translators.bing import BingTranslate

Bing = BingTranslate()
Bing_result = Bing.translate(text="江戸時代初期に建てられた天守や櫓等の主要建築物が現存し、国宝や重要文化財に指定されている。", destination_language="en", source_language="ja").result

print(Bing_result)

Traceback log:

C:\Users\CoolBeans>"C:\Users\CoolBeans\Desktop\bing test.py"
Traceback (most recent call last):
  File "C:\Users\CoolBeans\Desktop\bing test.py", line 4, in <module>
    Bing_result = Bing.translate(text="江戸時代初期に建てられた天守や櫓等の主要建築物が現存し、 国宝や重要文化財に指定されている。", destination_language="en", source_language="ja").result
  File "C:\Users\CoolBeans\AppData\Local\Programs\Python\Python39\lib\site-packages\translatepy\translators\base.py", line 110, in translate
    source_language, translation = self._translate(text, dest_code, source_code)
  File "C:\Users\CoolBeans\AppData\Local\Programs\Python\Python39\lib\site-packages\translatepy\translators\bing.py", line 161, in _translate
    response = self.session_manager.send("https://www.bing.com/ttranslatev3", data={'text': text, 'fromLang': source_language, 'to': destination_language})
  File "C:\Users\CoolBeans\AppData\Local\Programs\Python\Python39\lib\site-packages\translatepy\translators\bing.py", line 140, in send
    raise BingTranslateException(status_code)
translatepy.translators.bing.BingTranslateException: 205 | Unknown error. Error code: 205

Perhaps something changed on their ends? It was fine when I last used Bing translators on 8th January 2023. Many thanks for maintaining this awesome lib.

ZhymabekRoman commented 1 year ago

Yeah, same error: image I'll try to fix this error

GymnopedieNo4 commented 1 year ago

Thanks for the very prompt reply! Seems like there's a new abuse prevention token? Looking at: https://github.com/plainheart/bing-translate-api/commit/6858aea7f38d4cd317778a459cdf9361cf750d1d

ZhymabekRoman commented 1 year ago

Yeah! Exact! Thanks, fix works fine. I'll send PR to fix this image

GymnopedieNo4 commented 1 year ago

Yup, new PR works smooth as silk on my main script. Thank you so much for this above enterprise-grade support. 😁

ZhymabekRoman commented 1 year ago

@GymnopedieNo4, thank you, Satie, for using translatepy! By the way you my favorite composer :smile: