Jump to content
deanishe

Searchio! Auto-suggestion from search engines in different languages

Recommended Posts

On 7/27/2016 at 6:10 PM, deanishe said:

I'll look into the problems tomorrow/Friday.

 

I can't replicate the issue at the moment because I'm running the (currently) half-baked v2 rewrite that doesn't yet support the problem engines.

 

I also need to reinstall Alfred 2 to edit the workflow to maintain compatibility.

 

Unfortunately, simply editing a workflow in Alfred 3 will make it incompatible with Alfred 2, regardless of whether you use any Alfred 3-only features :(

 

Any news about this?

Share this post


Link to post

Not sure if it's just me or perhaps Google changed their API but Google Maps search with autosuggestions stopped working for me.

 

0AugxDW.png 

Share this post


Link to post
On 12/2/2016 at 4:37 AM, nikivi said:

Not sure if it's just me or perhaps Google changed their API but Google Maps search with autosuggestions stopped working for me.

 

0AugxDW.png 

Same for me, but for all google services (search, images, etc...). Amazon, DuckDuckGo and the others works fine so indeed maybe a problem from Google API...

Share this post


Link to post

Hey Dean,

 

If you will be rewriting this workflow in the future. Aside from Quora addition, which would be wonderful to have. Would it be possible to also add Twitter search with autosuggestions? 

 

Something like this : https://twitter.com/search-home 

 

But from Alfred.

Share this post


Link to post
On 09/12/2016 at 10:54 PM, mickaphd said:

Same for me, but for all google services (search, images, etc...). Amazon, DuckDuckGo and the others works fine so indeed maybe a problem from Google API...

 

Google Maps API is gone. I have a working replacement using the Google Places API, but you need an API key to use that one.

 

Version 2 in the develop branch has working Google Places, but doesn't support many other engines yet, as I still haven't decided on the right data model/JSON format. Install at your own risk.

Share this post


Link to post

How can I enforce a language before I make a search?

 

For example when searching for Yandex, I want to always search in Russian there. I am nearly always in US mode and even when I am in Russian, Alfred will always enforce english language. I just want to be able to run this Yandex Search script filter in Russian language only.

 

I tried using dispatch key code combo to simulate cmd + space, before running the trigger to the script filter but the dispatch key code didn't register the key code for some reason.

 

Thank you for any help. This workflow is phenomenal. 

 

Edited by nikivi

Share this post


Link to post

This applescript works however : 

 

on alfred_script(q)
    tell application "System Events" to key code 49 using {command down}
end alfred_script

 

:)

 

Share this post


Link to post
On 1/9/2017 at 0:35 PM, deanishe said:

 

Google Maps API is gone. I have a working replacement using the Google Places API, but you need an API key to use that one.

 

Version 2 in the develop branch has working Google Places, but doesn't support many other engines yet, as I still haven't decided on the right data model/JSON format. Install at your own risk.

 

Any progress with Version 2?

Share this post


Link to post

Version 2.0.0-alpha1 in the develop branch can be made to work, but it currently only supports a limited number of engines.

 

You need to add your Google Places API in the workflow configuration sheet for Google Maps to work.

 

Also, I haven't written the code to update info.plist yet, so you currently have to save searches in the workflow settings (keyword "searchio") and add the corresponding Script Filter to the workflow manually. The searches configured in the workflow when you install it will not work until you also save the corresponding searches.

 

I don't know how long it might take till an official release. I still haven't nailed down the right model for the search engine data.

Edited by deanishe

Share this post


Link to post
5 hours ago, deanishe said:

Also, I haven't written the code to update info.plist yet, so you currently have to save searches in the workflow settings (keyword "searchio") and add the corresponding Script Filter to the workflow manually. The searches configured in the workflow when you install it will not work until you also save the corresponding searches.

 

I'm not certain if I understood it, but I am getting this message:

 

uhYQnNp.png

Share this post


Link to post

Dude. You have to give me more info than a screenshot of the error…

 

What does the debugger say? Did you download the .alfredworkflow file or clone the repo?

Share this post


Link to post

The .alfredworkflow file was not version 2 but 1.8.1 when I downloaded the developer branch .zip yesterday so I had to create a new workflow on Alfred Preferences with the source with no success.

 

With the new .alfredworkflow file I could set up all searches successfully except Google Images and eBay (Google Maps aside) that seems to have a subtle different structure on Script Filter object:

 

./searchio search -e google-images -v en "$1"

 

./searchio search -e ebay -v de "$1"

For Google Images I tried ./searchio search -e google-images -v pt-br "$1", ./searchio search -e google-images-pt-br -v pt-br "$1" and some other unsuccessfully.

 

What am I missing?

Edited by PebaVermelho

Share this post


Link to post

UPDATE:

 

I got eBay to work with ./searchio search ebay-us "$1" but Google Images doesn't work with ./searchio search google-images-en "$1". In the latter case I am getting this:

 

[2017-03-03 00:20:41][ERROR: input.scriptfilter] Code 1: 00:20:40 workflow.py:2189 DEBUG    Workflow version : 2.0.0-alpha1
00:20:40 workflow.py:1596 DEBUG    Reading settings from `/Users/usuario/Library/Application Support/Alfred 3/Workflow Data/net.deanishe.alfred-searchio/settings.json` ...
00:20:40 workflow.py:2474 DEBUG    Update check not due
00:20:40 cli.py:62 DEBUG    args={'--help': False,
 '--version': False,
 '<args>': ['google-images-en', 'alfred'],
 '<command>': 'search'}
00:20:41 util.py:336 DEBUG    [200] https://suggestqueries.google.com/complete/search?client=firefox&ds=i&q=alfred&hl=en&safe=off
00:20:41 workflow.py:2207 ERROR    Parse error at 1:12 near token ] (])
Traceback (most recent call last):
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/workflow/workflow.py", line 2200, in run
    func(self)
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/searchio/cli.py", line 106, in cli
    return run(wf, argv)
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/searchio/cmd/search.py", line 146, in run
    results = cached_search(ctx, search, query)
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/searchio/cmd/search.py", line 127, in cached_search
    return ctx.wf.cached_data(key, _search, max_age=MAX_CACHE_AGE)
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/workflow/workflow.py", line 1833, in cached_data
    data = data_func()
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/searchio/cmd/search.py", line 104, in _search
    jx = parse(search.jsonpath)
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/jsonpath_rw/parser.py", line 14, in parse
    return JsonPathParser().parse(string)
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/jsonpath_rw/parser.py", line 32, in parse
    return self.parse_token_stream(lexer.tokenize(string))
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/jsonpath_rw/parser.py", line 55, in parse_token_stream
    return new_parser.parse(lexer = IteratorToTokenStream(token_iterator))
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/ply/yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/ply/yacc.py", line 1199, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/ply/yacc.py", line 193, in call_errorfunc
    r = errorfunc(token)
  File "/Users/usuario/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C313179B-50F9-4D6C-A7DF-242971F70C65/lib/jsonpath_rw/parser.py", line 69, in p_error
    raise Exception('Parse error at %s:%s near token %s (%s)' % (t.lineno, t.col, t.value, t.type))
Exception: Parse error at 1:12 near token ] (])
00:20:41 workflow.py:2210 INFO     For assistance, see: https://github.com/deanishe/alfred-searchio/issues
00:20:41 workflow.py:2231 DEBUG    Workflow finished in 0.386 seconds.

Share this post


Link to post

The engine definition is incorrect for Google Images (as noted, I haven't finished finalising the definition format yet). The simplest fix is to correct the google-images.json file in the workflow itself at lib/searchio/engines/google-images.json. Remove the json_path key from that file and re-save the Google Images (English) search (you may have to delete the existing one first) to ensure the search definition is correct.

Share this post


Link to post
7 hours ago, PebaVermelho said:

For Google Images I tried ./searchio search -e google-images -v pt-br "$1", ./searchio search -e google-images-pt-br -v pt-br "$1" and some other unsuccessfully.

 

At lot of the searches in the workflow are left over from version 1 and thus have this old calling format. You must use the format ./searchio search google-images-pt-br "$1".

 

The search ID is the same as the filename of its definition, and they're saved in ~/Library/Application Support/Alfred 3/Workflow Data/net.deanishe.alfred-searchio

Share this post


Link to post
7 hours ago, PebaVermelho said:

The .alfredworkflow file was not version 2 but 1.8.1

 

That's the wrong file. I've just rebuilt the .alfredworkflow file and pushed the fixed Google Images definition to GitHub.

Share this post


Link to post
10 hours ago, deanishe said:

The engine definition is incorrect for Google Images (as noted, I haven't finished finalising the definition format yet). The simplest fix is to correct the google-images.json file in the workflow itself at lib/searchio/engines/google-images.json. Remove the json_path key from that file and re-save the Google Images (English) search (you may have to delete the existing one first) to ensure the search definition is correct.

 

It worked. Thank you!

Share this post


Link to post
On 1/9/2017 at 0:35 PM, deanishe said:

 

Google Maps API is gone. I have a working replacement using the Google Places API, but you need an API key to use that one.

 

Version 2 in the develop branch has working Google Places, but doesn't support many other engines yet, as I still haven't decided on the right data model/JSON format. Install at your own risk.

 

I have been using version 2 and got a key for Google Places API Web Service, but the search doesn't take my location into account, so I have to type my city's name. Is this the expected behavior?

Share this post


Link to post
1 hour ago, xilopaint said:

Is this the expected behavior?

 

Not precisely. From the API docs:

 

Quote

If you do not supply the location and radius, the API will attempt to detect the user's location from their IP address, and will bias the results to that location.

 

https://developers.google.com/places/web-service/autocomplete#location_biasing

 

So, it should prefer results near to you.

 

It is possible to specify a location and radius. I guess I could add those as options in the configuration sheet if the geolocation via IP address sucks. 

 

 

Share this post


Link to post

I've looked into this, and setting a location and radius for the Place search should get you the results you want.

 

I've pushed an updated version to the develop branch with GOOGLE_PLACES_LOCATION and GOOGLE_PLACES_RADIUS options in the workflow configuration sheet. You must set both for it to work, and the location must be in decimal format, e.g. 51.450833,7.013056, and the radius is in metres.

 

You must also delete your existing search and re-add it (or edit the config by hand to add the parameters to the URL). You can delete the search via the searchio command (it shows an error, as the feature isn't complete, but it does delete the configuration), or you can remove it by hand by entering searchio workflow:opendata and removing the corresponding file(s) from the searches directory.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...