xfslove / alfred-google-translate

Alfred 3 workflow - translate with google api💵🚫
MIT License
618 stars 65 forks source link

HTTPError: Response code 404 (Not Found) #51

Closed alfredo-milani closed 5 years ago

alfredo-milani commented 5 years ago

Once downloaded and configured alfred-language-configuration and installed node binary, this workflow gives the following error (input: tr hello):

HTTPError: Response code 404 (Not Found)
Url: https://translate.google.it//translate_a/single?client=gtx&sl=en&tl=it&hl=en&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=7&q=hello&tk=451152.18915
    at /Users/alfredo/.config/Alfred 4/Alfred.alfredpreferences/workflows/user.workflow.D3FB80B9-D5BA-4D6D-AC2D-44219BA0A779/node_modules/got/index.js:123:13

-
Google Translate 2.0.8
Alfred 4.0.5
darwin 18.7.0

Seems to be an error due to malformed URL. The string in excess is "translate_a/single". Once that string has been deleted, the request proceeds successfully, at least on browser. If I manually remove the string '/translate_a/single' in the translate.js file (line 10), I get JSON error:

SyntaxError: Unexpected token < in JSON at position 0
Url: https://translate.google.it/?client=gtx&sl=en&tl=it&hl=en&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=7&q=hello&tk=211563.365023
    at JSON.parse (<anonymous>)
    at /Users/alfredo/.config/Alfred 4/Alfred.alfredpreferences/workflows/user.workflow.D3FB80B9-D5BA-4D6D-AC2D-44219BA0A779/translate.js:29:29

-
Google Translate 2.0.8
Alfred 4.0.5
darwin 18.7.0
xfslove commented 5 years ago

I'll take a look.

xfslove commented 5 years ago

@alfredo-milani , your domain variable should be https://translate.google.it instead of https://translate.google.it/

alfredo-milani commented 5 years ago

Thanks. The final slash was the problem.