Use a fork of googletrans since the original isn't working

https://github.com/ssut/py-googletrans/issues/234#issuecomment-736314530
This commit is contained in:
blank X 2020-12-01 19:22:16 +07:00
parent 5e63e72089
commit f30f84015a
2 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,6 @@
googletrans # https://github.com/ssut/py-googletrans/issues/234#issuecomment-736314530
git+https://github.com/alainrouillon/py-googletrans@feature/enhance-use-of-direct-api
pyrogram pyrogram
tgcrypto tgcrypto
requests requests

View File

@ -39,7 +39,8 @@ async def translate(client, message):
def _translate(): def _translate():
while True: while True:
try: try:
return googletrans.Translator().translate(text, src=src_lang, dest=dest_lang) # https://github.com/ssut/py-googletrans/issues/234#issuecomment-736314530
return googletrans.Translator(service_urls=['translate.googleapis.com']).translate(text, src=src_lang, dest=dest_lang)
except AttributeError: except AttributeError:
time.sleep(0.5) time.sleep(0.5)
result = await client.loop.run_in_executor(None, _translate) result = await client.loop.run_in_executor(None, _translate)