Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yandex 403 #94

Open
re7gog opened this issue Nov 3, 2022 · 13 comments
Open

Yandex 403 #94

re7gog opened this issue Nov 3, 2022 · 13 comments

Comments

@re7gog
Copy link

re7gog commented Nov 3, 2022

Yandex translate doesn't work at all (google for example is fine)

Code:
import translators
print(translators.yandex("Привет"))

Output:
Using state Moscow server backend.
Traceback (most recent call last):
File "D:\Code\pythonProject\main.py", line 2, in
print(translators.yandex("Привет"))
File "D:\Code\pythonProject\venv\lib\site-packages\translators\apis.py", line 1418, in yandex_api
r.raise_for_status()
File "D:\Code\pythonProject\venv\lib\site-packages\requests\models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://translate.yandex.com/

@bropines
Copy link

I'm thinking of using the implementation from this server in Yandex translator. I use it myself and it works great.
https://github.com/FOSWLY/translate-backend

@bropines
Copy link

I also have a question. Why not divide all translators into modules? As I understand it, they are loaded from one file, which looks a bit like a crutch.

@bropines
Copy link

@UlionTse ?

@UlionTse
Copy link
Owner

@bropines Sorry, bro. I saw it before, but forgot to reply after reading other questions. Thank you for the reference. Due to work reasons, the next update will be during the International Labor Day.

@UlionTse
Copy link
Owner

I also have a question. Why not divide all translators into modules? As I understand it, they are loaded from one file, which looks a bit like a crutch.

It's a personal hobby. Since around 40 separate files makes the code very boring and garbage bin-like, I prefer to use classes and inheritance to build complex code and easily count how many lines of code the project has.

@bropines
Copy link

@bropines Sorry, bro. I saw it before, but forgot to reply after reading other questions. Thank you for the reference. Due to work reasons, the next update will be during the International Labor Day.

You can take your time and spend the holidays with your loved ones.

It's a personal hobby. Since around 40 separate files makes the code very boring and garbage bin-like, I prefer to use classes and inheritance to build complex code and easily count how many lines of code the project has.

Well, basically your job, do it the way it's convenient. I'm just used to projects where everything is divided into 1000 million modules. Nothing, and I figured it out in general. Thanks for the work.

@UlionTse
Copy link
Owner

Respect and Thanks.

@UlionTse
Copy link
Owner

UlionTse commented May 8, 2024

@bropines Bro, please pip install --upgrade translators==5.9.2

@bropines
Copy link

bropines commented May 10, 2024

Yes, I saw it, thank you. I will check it Through my translator program and we can close the issue.

@bropines
Copy link

@UlionTse
There's a problem here. He says that there is no Japanese, but when I run the API of the library that I downloaded earlier, it translates from Japanese without any questions. At the same time, if I write auto it translates, if I write the language code ja it gives an error.

JA

import translators as ts

# Просмотр доступных переводчиков
print(ts.translators_pool)

# Пример использования функции translate_text с Яндекс Переводчиком
translated_text = ts.translate_text(
    query_text="もっと球を見る意識が大事だ! ! あとはできているの. . . ",
    translator='yandex',
    from_language='ja',
    to_language='ru'
)

print(translated_text)

log

╰─ python .\trasnasa.py
['alibaba', 'apertium', 'argos', 'baidu', 'bing', 'caiyun', 'cloudTranslation', 'deepl', 'elia', 'google', 'hujiang', 'iciba', 'iflytek', 'iflyrec', 'itranslate', 'judic', 'languageWire', 'lingvanex', 'niutrans', 'mglip', 'mirai', 'modernMt', 'myMemory', 'papago', 'qqFanyi', 'qqTranSmart', 'reverso', 'sogou', 'sysTran', 'tilde', 'translateCom', 'translateMe', 'utibet', 'volcEngine', 'yandex', 'yeekit', 'youdao']
Traceback (most recent call last):
  File "D:\Рабочий стол\Рабочий стол Clear\trasnasa.py", line 7, in <module>
    translated_text = ts.translate_text(
  File "G:\Ballon-translator-portable-main\venv\lib\site-packages\translators\server.py", line 5555, in translate_text
    return self.translators_dict[translator](query_text=query_text, from_language=from_language, to_language=to_language, **kwargs)
  File "G:\Ballon-translator-portable-main\venv\lib\site-packages\translators\server.py", line 117, in _wrapper
    return func(*args, **kwargs)
  File "G:\Ballon-translator-portable-main\venv\lib\site-packages\translators\server.py", line 288, in _wrapper
    return func(*args, **{**kwargs, **{'query_text': query_text}})
  File "G:\Ballon-translator-portable-main\venv\lib\site-packages\translators\server.py", line 2387, in yandex_api
    from_language, to_language = self.check_language(from_language, to_language, self.language_map, output_zh=self.output_zh)
  File "G:\Ballon-translator-portable-main\venv\lib\site-packages\translators\server.py", line 194, in check_language
    raise TranslatorError('Unsupported from_language[{}] in {}.'.format(from_language, sorted(language_map.keys())))
translators.server.TranslatorError: Unsupported from_language[ja] in ['az', 'be', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fi', 'fr', 'hr', 'hu', 'hy', 'it', 'lt', 'lv', 'mk', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sq', 'sr', 'sv', 'tr', 'uk'].

AUTO

import translators as ts

# Просмотр доступных переводчиков
print(ts.translators_pool)

# Пример использования функции translate_text с Яндекс Переводчиком
translated_text = ts.translate_text(
    query_text="もっと球を見る意識が大事だ! ! あとはできているの. . . ",
    translator='yandex',
    from_language='auto',
    to_language='ru'
)

print(translated_text)

log

╰─ python .\trasnasa.py
['alibaba', 'apertium', 'argos', 'baidu', 'bing', 'caiyun', 'cloudTranslation', 'deepl', 'elia', 'google', 'hujiang', 'iciba', 'iflytek', 'iflyrec', 'itranslate', 'judic', 'languageWire', 'lingvanex', 'niutrans', 'mglip', 'mirai', 'modernMt', 'myMemory', 'papago', 'qqFanyi', 'qqTranSmart', 'reverso', 'sogou', 'sysTran', 'tilde', 'translateCom', 'translateMe', 'utibet', 'volcEngine', 'yandex', 'yeekit', 'youdao']
важно осознавать, что нужно чаще видеть мяч! ! Остальное сделано. . .

@UlionTse
Copy link
Owner

@bropines
I know this. In the reference code you provided, there are indeed few types of acquisition languages involved. Therefore, it is recommended to use auto. I didn't see Chinese in language_map, but Chinese can also be used.

lang_data = self.get_request_data(ss=ss, method='getLangs', params={}, timeout=timeout, proxies=proxies)

@bropines
Copy link

maybe you should add a message like "try auto" in response to a language that does not exist?

@bropines
Copy link

@bropines I know this. In the reference code you provided, there are indeed few types of acquisition languages involved. Therefore, it is recommended to use auto. I didn't see Chinese in language_map, but Chinese can also be used.

lang_data = self.get_request_data(ss=ss, method='getLangs', params={}, timeout=timeout, proxies=proxies)

@UlionTse
Also, there is a problem with deepl, which seems to have already been fixed in deeplx.
Error when translating text: 429 Client Error: for url: https://www2.deepl.com/jsonrpc?method=LMT_split_text

Here is my JS code that roughly uses the same logic.
https://github.com/bropines/Deeplx-vercel/blob/main/translate.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants