soimort / translate-shell

:speech_balloon: Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc.
https://www.soimort.org/translate-shell
The Unlicense
6.94k stars 391 forks source link

[Bing] Very often "Null response" in version 0.9.6.11-release #319

Closed Rosika2 closed 2 years ago

Rosika2 commented 5 years ago

Hi,

I´ve been using translate-shell for quite a while now and has worked perfectly. Now that I´m using the latest version 0.9.6.11-release I get frequent problems.

Every once in a while I get the response

[ERROR] Null response.
[ERROR] Oops! Something went wrong and I can't translate it for you :( 

But not always.

Example: ./trans -shell de:en gives me an interactive prompt. When typing "Danke" it replies amongst other output "thank you", which is o.k. But that doesn´t happen every time. Very often I get the aforementioned error-message.

BTW: It´s the same with gawk -f (curl -Ls git.io/translate | psub) -- -shell (I use fish).

What might be the problem there?

Greetings Rosika

P.S.: System: Linux/Lubuntu 16.04.3 LTS, 64 bit

soimort commented 5 years ago

That often happens when Google has banned your IP address due to too many requests. It could last hours to a day.

Unfortunately there's nothing much I can do. Don't abuse the service, give it a rest, and wait another 24 hours before Google unbans your IP.

Rosika2 commented 5 years ago

Hello soimort,

thank you very much for your reply. I understand. Although it seems a bit odd that I get the same problem when invoking another translation machine like ./trans -shell -e bing de:en . Furthermore the old version 0.9.6.5-release seemed not to provoke a Google ban.

Nevertheless thanks again for the clarification.

Greetings. Rosika

soimort commented 5 years ago

Furthermore the old version 0.9.6.5-release seemed not to provoke a Google ban.

I don't think the ban is related to versions, though. Same API , same set of HTTP requests. It's just Google started blocking automated requests more proactively than in the old days.

If you have the same problem with Bing, please append -debug to the command and post the output here.

Rosika2 commented 5 years ago

@soimort: Thanks.

It's just Google started blocking automated requests more proactively than in the old days.

That´s probably it. Thanks for pointing that out.

As far as Bing is concerned I appended -debug and got the following result:

Command: ./trans -shell -e bing -debug de:en Interactive input: "Das ist schön."

Deutsch> Das ist schön.
  16 bytes > HTTP/1.1 200 OK
  23 bytes > Cache-Control: private
  20 bytes > Content-Length: 103
  46 bytes > Content-Type: application/json; charset=utf-8
  62 bytes > P3P: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND"
  93 bytes > Set-Cookie: SRCHD=AF=NOFORM; domain=.bing.com; expires=Sun, 20-Sep-2020 14:10:02 GMT; path=/
 136 bytes > Set-Cookie: SRCHUID=V=2&GUID=5597E88A41B74B29BD981346A5D8DAAB&dmnchg=1; domain=.bing.com; expires=Sun, 20-Sep-2020 14:10:02 GMT; path=/
  98 bytes > Set-Cookie: SRCHUSR=DOB=20190827; domain=.bing.com; expires=Sun, 20-Sep-2020 14:10:02 GMT; path=/
  79 bytes > Set-Cookie: _SS=SID=13013C876E7D6951367131426F0C6807; domain=.bing.com; path=/
 101 bytes > X-MSEdge-Ref: Ref A: 3DFD457B5680491B9A159EF40589B320 Ref B: FRAEDGE0913 Ref C: 2019-08-27T14:10:02Z
  96 bytes > Set-Cookie: _EDGE_S=F=1&SID=13013C876E7D6951367131426F0C6807; path=/; httponly; domain=bing.com
  96 bytes > Set-Cookie: _EDGE_V=1; path=/; httponly; expires=Sun, 20-Sep-2020 14:10:02 GMT; domain=bing.com
 114 bytes > Set-Cookie: MUID=03A88931252B6950328F84F4245A685B; path=/; expires=Sun, 20-Sep-2020 14:10:02 GMT; domain=bing.com
 108 bytes > Set-Cookie: MUIDB=03A88931252B6950328F84F4245A685B; path=/; httponly; expires=Sun, 20-Sep-2020 14:10:02 GMT
  36 bytes > Date: Tue, 27 Aug 2019 14:10:02 GMT
  18 bytes > Connection: close
   1 bytes > 
 103 bytes > [{"detectedLanguage":{"language":"de","score":1.0},"translations":[{"text":"That's nice.","to":"en"}]}]
content = '''
[{"detectedLanguage":{"language":"de","score":1.0},"translations":[{"text":"That's nice.","to":"en"}]}]
'''
tokens = ["[", "{", "\"detectedLanguage\"", ":", "{", "\"language\"", ":", "\"de\"", ",", "\"score\"", ":", "1.0", "}", ",", "\"translations\"", ":", "[", "{", "\"text\"", ":", "\"That's nice.\"", ",", "\"to\"", ":", "\"en\"", "}", "]", "}", "]"]
ast = {
"0,0,detectedLanguage,language" "\"de\""
"0,0,detectedLanguage,score"    "1.0"
"0,0,translations,0,text"   "\"That's nice.\""
"0,0,translations,0,to" "\"en\""
}
  16 bytes > HTTP/1.1 200 OK
  23 bytes > Cache-Control: private
  20 bytes > Content-Length: 106
  46 bytes > Content-Type: application/json; charset=utf-8
  62 bytes > P3P: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND"
  93 bytes > Set-Cookie: SRCHD=AF=NOFORM; domain=.bing.com; expires=Sun, 20-Sep-2020 14:10:03 GMT; path=/
 136 bytes > Set-Cookie: SRCHUID=V=2&GUID=D7026AF42B2D4064B88E4513DA64F56D&dmnchg=1; domain=.bing.com; expires=Sun, 20-Sep-2020 14:10:03 GMT; path=/
  98 bytes > Set-Cookie: SRCHUSR=DOB=20190827; domain=.bing.com; expires=Sun, 20-Sep-2020 14:10:03 GMT; path=/
  79 bytes > Set-Cookie: _SS=SID=2F73E9D9735D697C0AF6E41C72E86830; domain=.bing.com; path=/
 101 bytes > X-MSEdge-Ref: Ref A: 6A2B4ACD10CE468394553AF64B1C929B Ref B: FRAEDGE0306 Ref C: 2019-08-27T14:10:03Z
  96 bytes > Set-Cookie: _EDGE_S=F=1&SID=2F73E9D9735D697C0AF6E41C72E86830; path=/; httponly; domain=bing.com
  96 bytes > Set-Cookie: _EDGE_V=1; path=/; httponly; expires=Sun, 20-Sep-2020 14:10:03 GMT; domain=bing.com
 114 bytes > Set-Cookie: MUID=307AAD3A7F0F610E3377A0FF7EBA6029; path=/; expires=Sun, 20-Sep-2020 14:10:03 GMT; domain=bing.com
 108 bytes > Set-Cookie: MUIDB=307AAD3A7F0F610E3377A0FF7EBA6029; path=/; httponly; expires=Sun, 20-Sep-2020 14:10:03 GMT
  36 bytes > Date: Tue, 27 Aug 2019 14:10:02 GMT
  18 bytes > Connection: close
   1 bytes > 
 105 bytes > [{"detectedLanguage":{"language":"de","score":1.0},"translations":[{"text":"Das ist schön.","to":"de"}]}]
  16 bytes > HTTP/1.1 200 OK
  23 bytes > Cache-Control: private
  19 bytes > Content-Length: 92
  46 bytes > Content-Type: application/json; charset=utf-8
  62 bytes > P3P: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND"
  93 bytes > Set-Cookie: SRCHD=AF=NOFORM; domain=.bing.com; expires=Sun, 20-Sep-2020 14:10:04 GMT; path=/
 136 bytes > Set-Cookie: SRCHUID=V=2&GUID=BA083E0D1FE84D8186A43D36FFC47E03&dmnchg=1; domain=.bing.com; expires=Sun, 20-Sep-2020 14:10:04 GMT; path=/
  98 bytes > Set-Cookie: SRCHUSR=DOB=20190827; domain=.bing.com; expires=Sun, 20-Sep-2020 14:10:04 GMT; path=/
  79 bytes > Set-Cookie: _SS=SID=11490E4F2DB264FE07FD038A2C0765B5; domain=.bing.com; path=/
 101 bytes > X-MSEdge-Ref: Ref A: 69463CAE3A6D4043ACEB9B4C82618C5F Ref B: FRAEDGE0509 Ref C: 2019-08-27T14:10:04Z
  96 bytes > Set-Cookie: _EDGE_S=F=1&SID=11490E4F2DB264FE07FD038A2C0765B5; path=/; httponly; domain=bing.com
  96 bytes > Set-Cookie: _EDGE_V=1; path=/; httponly; expires=Sun, 20-Sep-2020 14:10:04 GMT; domain=bing.com
 114 bytes > Set-Cookie: MUID=1EF1F9ADF1B46D1433D3F468F0016CA7; path=/; expires=Sun, 20-Sep-2020 14:10:04 GMT; domain=bing.com
 108 bytes > Set-Cookie: MUIDB=1EF1F9ADF1B46D1433D3F468F0016CA7; path=/; httponly; expires=Sun, 20-Sep-2020 14:10:04 GMT
  36 bytes > Date: Tue, 27 Aug 2019 14:10:03 GMT
  18 bytes > Connection: close
   1 bytes > 
  90 bytes > [{"normalizedSource":"Das ist schön.","displaySource":"Das ist schön.","translations":[]}]
dicContent = '''
[{"normalizedSource":"Das ist schön.","displaySource":"Das ist schön.","translations":[]}]
'''
dicTokens = ["[", "{", "\"normalizedSource\"", ":", "\"Das ist schön.\"", ",", "\"displaySource\"", ":", "\"Das ist schön.\"", ",", "\"translations\"", ":", "[", "]", "}", "]"]
dicAst = {
"0,0,displaySource" "\"Das ist schön.\""
"0,0,normalizedSource"  "\"Das ist schön.\""
}
-- display original text
Das ist schön.

-- display major translation
That's nice.

-- display source language -> target language
[ Deutsch -> English ]
-- display dictionary entries

Deutsch> schönes Wetter
  31 bytes > HTTP/1.1 301 Moved Permanently
  53 bytes > Location: http://www.bing.com/ttranslatev3?mkt=zh-CN
  27 bytes > Server: Microsoft-IIS/10.0
 101 bytes > X-MSEdge-Ref: Ref A: 6A99AE2B4478445389C6319A0F48C911 Ref B: FRAEDGE0819 Ref C: 2019-08-27T14:10:24Z
  36 bytes > Date: Tue, 27 Aug 2019 14:10:24 GMT
  18 bytes > Connection: close
  18 bytes > Content-Length: 0
   1 bytes > 
content = '''

'''
tokens = 
ast = 
[ERROR] Oops! Something went wrong and I can't translate it for you :(

Deutsch> 

Greetings Rosika

ChrisLuNlm commented 5 years ago

Hi,

I am running to the same problem with Google limitation. Does Bing have limitation as well? Do you have any suggestion? Such as how many requests I can send with a time window? I got banned after about 100 requests (by machine)? Any suggestion will be appreciated! Thank you in advance!

Rosika2 commented 4 years ago

@ChrisLuNlm: Hi,

I just wanted to run a direct comparison of standard and bing ("trans -shell -e bing de:ru"). It sems odd but at present I won´t get kicked out by either google or bing. I tried a lot . :) But that isn´t representative at all. In the past I tried out google as well as bing and got kicked out by both of them. Sorry I can´t tell you anything more positive.

Greetings. Rosika

Rosika2 commented 4 years ago

Hello again,

I think in the meantime I´ve worked out why I rather often get

[ERROR] Null response.
[ERROR] Oops! Something went wrong and I can't translate it for you :(

That inadvertently happens whenever I use my umts-stick for internet connection instead of wlan. The thing is: I type my request for translation into the terminal and then hit the return-key. But it´s the time that the stick takes to push out the send request which is crucial. It takes 2 -3 seconds which seems to be too much. I get the error-message.

To prove it: When sending the exact same request for translation right afterwards (a 2nd time) I immediately get the correct translation as an answer. That´s because my umts-stick i still in some sort of "connected" mode. The LED is light blue (instead of dark blue) which gives it away.

So to sum up: Traslate_shell should give more time (say a few seconds more) for query response before it times out with the error-message.

Can something be done about it? Is there a config for changing the respective value?

Greetings Rosika

soimort commented 4 years ago

Thanks for the information -- Yes, I agree that there should be some option to set a timeout value.(currently it's hardcoded and can't be configured for)

Rosika2 commented 4 years ago

@soimort: Thanks for the info and adding the matter to encancement.

ipstone commented 3 years ago

Is there a recommended timeout/wait setting that we can avoid being 'blocked'? I don't mind waiting for 1-2 mins between paragraphs but that sure if that will resolve the issue. It might be good to find out what are the google's criteria to block ip address for using translation...

soimort commented 3 years ago

Is there a recommended timeout/wait setting that we can avoid being 'blocked'?

hard to find out where google's bar is. One request /sec can easily lead to IP restriction; one request /min is most likely fine, based on my everyday normal usage.

Having an option for setting the time gap between requests sounds a reasonable idea.