Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Parse Google Translate directly instead of using the public API #17

Open
ghost opened this issue Sep 27, 2021 · 14 comments
Open

Parse Google Translate directly instead of using the public API #17

ghost opened this issue Sep 27, 2021 · 14 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ghost
Copy link

ghost commented Sep 27, 2021

Describe the problem or limitation you are having
The public Google Translate API is too restrictive, and returns "Too many requests" even after a few requests.

Describe the solution you'd like
Parse the website instead of using the public API.

Describe alternatives you've considered
Switching the translation engine. Not the best solution for some languages, which translate best in Google Translate

Additional context
QTranslate is most likely doing this, since the error "Too many requests" never occurs there.

@Shatur
Copy link
Member

Shatur commented Sep 27, 2021

I think we could do even better - look what kind of requests Google Translate website sends. This is how Bing API works.

@Shatur Shatur transferred this issue from crow-translate/crow-translate Sep 27, 2021
@ghost
Copy link
Author

ghost commented Sep 27, 2021

I've found this:
https://pythonrepo.com/repo/ssut-py-googletrans-python-third-party-apis-wrappers
Perhaps it can be helpful. It says:

You may wonder why this library works properly, whereas other approaches such like goslate won't work since Google has updated its translation service recently with a ticket mechanism to prevent a lot of crawler programs.

I eventually figure out a way to generate a ticket by reverse engineering on the obfuscated and minified code used by Google to generate such token, and implemented on the top of Python. However, this could be blocked at any time.

If necessary I could probably write a JS parser as well (I know JS, some Nodejs and Electron).

@Shatur
Copy link
Member

Shatur commented Sep 27, 2021

I've found this:

Thanks, it's a nice reference!
But for now I running out of time, so PR's are welcome here.

If necessary I could probably write a JS parser as well (I know JS, some Nodejs and Electron).

Unfortunately, we need a C++ programmer or wait until I have more free time :)

@Shatur Shatur added enhancement New feature or request help wanted Extra attention is needed labels Oct 8, 2021
@VolkMilit
Copy link
Contributor

VolkMilit commented Oct 10, 2021

This python program use the API, if I'm not mistaken: https://github.com/ssut/py-googletrans/blob/master/googletrans/gtoken.py#L13

Yeep: https://github.com/ssut/py-googletrans/blob/master/googletrans/client.py#L26

@ghost
Copy link
Author

ghost commented Oct 20, 2021

@Shatur could you provide an option for a terminal command for Google Translate. So everyone could write their own parser / find an API and simply return that with a command line tool. For example, you could just outline in which format the data should be returned, so users can write their parsers in any language, or use any translator or dictionary they want (potentially).

@Shatur
Copy link
Member

Shatur commented Oct 20, 2021

could you provide an option for a terminal command for Google Translate. So everyone could write their own parser / find an API and simply return that with a command line tool.

Not sure if I understand you correctly, but looks like you describing curl / wget.

@ghost
Copy link
Author

ghost commented Oct 20, 2021

I had originally in mind something like a user-defined command line, for example:

translatetext "text from translator"

So the user could create their own command-line tool (with the name translatetext in this case) and return data after executing it. I guess it could be something else, like curl / wget. Anything that can work to return data after executing the command in terminal.

Edit: nevermind, I realized I can just change the URL in the source code and rebuild if I really need it. Hopefully Yandex TTS starts working, since Yandex seems to be probably as good as Google in translating. And maybe I can find someone who could code in C++ and help here.

@Shatur
Copy link
Member

Shatur commented Oct 20, 2021

Oh, I get it now!
It would be better if translators were built in for a better user experience.
I would rather improve the support for Google Translate, which all users will benefit from, than support an additional parsing format that people will implement themselves.

@ghost
Copy link

ghost commented Dec 23, 2023

@Shatur does qonlinetranslator use google translate's mobile stuff which yields worse translation?

@Shatur
Copy link
Member

Shatur commented Dec 23, 2023

It uses deskop API, but uses mobile user agent in order to bypass google checks.

@ghost
Copy link

ghost commented Dec 23, 2023

@Shatur I'm using crow for subtitle translation, so I wondered if the google engine you implemented brings an error or a limitation, temporary ban depending on the usage. When I checked this repo, I didn't see anyone who encountered such an error, maybe something like this was reported in crow's own repo or maybe they reported it directly to you via e-mail.

@Shatur
Copy link
Member

Shatur commented Dec 23, 2023

Unfortunately, it's a common problem. People just reported it to the app repo: https://github.com/crow-translate/crow-translate
I afraid that the only workaround is to switch translation engine.

@ghost
Copy link

ghost commented Dec 23, 2023

@Shatur mpv script uses this command, I wonder do I have to delete the -e to make crow auto switch the engine when it get error on google engine or would it switch automatically?

	local args = {
			'crow',
			'-l', from,
			'-t', to,
			'-e', 'google',
			'-b', escaped
		}
,,,

@Shatur
Copy link
Member

Shatur commented Dec 23, 2023

Unfortunately, no, there is no such feature :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Development

No branches or pull requests

2 participants