hubot-archive / hubot-google-images

A hubot script that interacts with the Google Images API
126 stars 66 forks source link

Google search api having issues or is there a change needed? #10

Closed gyoza closed 9 years ago

gyoza commented 9 years ago

No longer getting gifs when using animate... Not entirely sure why, is there something that has been changed or is the since depreciated search API now defunct? Thanks.

louim commented 9 years ago

What version are you using? Anything interesting in the Hubot logs?

RileyMills commented 9 years ago

Just updated the script to try to fix this issue. Still having the same results using the old API. Don't have a CSE set up.

gyoza commented 9 years ago

I used the latest version available here.

james-ingold commented 9 years ago

+1 having the same issue here

HaroldPutman commented 9 years ago

The deprecated API results seem to not honor imgtype=animated anymore

https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q=cute+kittens&safe=active&imgtype=animated

Gives the same results as without the imgtype defined. That parameter is listed as "experimental" in the documentation so maybe the experiment is over?

We have great success animating with the CSE version.

gyoza commented 9 years ago

@HaroldPutman Any idea where to get the CSE ID? When I use the default google search engine it gives me errors.. Any tips would be appreciated.

louim commented 9 years ago

@gyoza Information on how to setup Google CSE is here: https://developers.google.com/custom-search/docs/tutorial/creatingcse

gyoza commented 9 years ago

I figured it out... it is because I did not have "images" turned on :) Thanks for the link though!

gyoza commented 9 years ago

Man, 100 queries a day is a huge drag :(

gyoza commented 9 years ago

You know a ghetto way to do this is to add the as_filetype=gif to the list and then deconstruct the top 10 results in question to see if they have more than one frame (aka a real gif) and post that image. ha... its super ghetto but if they decide to never "fix" this for us and we dont want to be limited to 100 queries a day it may be something worth looking into..

RileyMills commented 9 years ago

Not a bad thought. Heck, just restricting to .gif files would increase the odds of getting an animated image result.

ryanbmilbourne commented 9 years ago

+1 We're seeing the same issue.

What's interesting is that we sometimes get a gif, sometimes not. The gifs are rare, but we're not getting only images when using animate me.

HaroldPutman commented 9 years ago

@gyoza that approach may not be so ghetto. The CSE version limits the results to gif and includes "AND animated" in the query. There's no other option for this in the new API. This works most of the time.

FWIW, we have a team of 40 developers and have not ever had more that 45 image queries in a day. But maybe we're not as fun as most people :smirk_cat:

alehandrof commented 9 years ago

Can someone furnish an example? I have created a Custom Search Engine and a project in the Developers Console, but I'm getting 404 errors from hubot.

HaroldPutman commented 9 years ago

Did you set the environment variables before starting hubot? Something like this (obviously using your real ids and keys)

export HUBOT_GOOGLE_CSE_ID=0493...7K
export HUBOT_GOOGLE_CSE_KEY=GGP...bsX
alehandrof commented 9 years ago

@HaroldPutman OK, I was using a Project ID instead of the CSE Key. I can't find this value anywhere :-/

HaroldPutman commented 9 years ago

Find the key here: Visit https://code.google.com/apis/console select your project and then choose Credentials under APIs & Auth.

alehandrof commented 9 years ago

Got it :trophy:

@HaroldPutman: Thank you. Without your help I would still be looking.

seeReadCode commented 9 years ago

To clarify the steps a bit

  1. Create a CSE via these instructions. I had to set a search criteria but then I removed it later.
  2. Turn on images in Edit Search Engine > Setup > Basic > Image Search
  3. Get ID in Edit Search Engine > Setup > Basic > Details (via these instructions)
  4. Get key here https://code.google.com/apis/console
  5. Update your conf (and your modules if necessary)
  6. Test hubot animate me gravy

gravy

Thanks all!

jasonleibowitz commented 9 years ago

I'm having trouble setting up the Google CSE. I've following the instructions provided previously linked to, but when I search for "gravy" it only returns patent application data. Can someone help me ensure I have the right options selected for CSE (screenshot of CSE Control Panel below). The main question is what site should I specify to search through? (I assumed www.google.com).

When I use the query URL in the browser this is the response I get. It is working, but not in the way this hubot extension expects. There's no res.statusCode returned, so hubot-google-images responds with a 400 error.

Thanks for the help.

screen shot 2015-09-03 at 11 18 05 am

screen shot 2015-09-03 at 11 18 12 am

screen shot 2015-09-03 at 11 18 16 am

alehandrof commented 9 years ago

@jasonleibowitz I think you needed to add at least one site to create the search engine.

But then you should remove them and change the "Sites search" option:

custom_search_-_basic

(Or, at least, that has worked for me.)

jasonleibowitz commented 9 years ago

@alehandrof That was the answer. Thank you so much!

danoc commented 9 years ago

Worked for me as well. This was way too complicated.

atomicframeworks commented 9 years ago

Worked for me. Thank you everyone for the help!

ryanbmilbourne commented 9 years ago

I'm not sure if CSE is the best option, given the artificially low API request limit that Google is imposing. Our team is more active with our hubot and we burned through our request limit in ~4 hours.

I was able to add the as_filetype parameter to the deprecated API request and get GIFs back, but @gyoza 's method will be required to root out the single-frame GIFs. It might be worth putting into the code-base if it means that this project can continue support limitless GIF getting via the deprecated API.

liquidmetal commented 9 years ago

I was able to get the giphy option working. Should I submit a pull request for this? Are there any reasons to not go with giphy?

louim commented 9 years ago

@liquidmetal if you can implement as an option, pull request are very welcome!

danoc commented 9 years ago

Is anyone else not a huge fan of Giphy's results? I've always found that animate me in Hubot is miles better than Slack's /giphy integration. Not sure why that is the case though.

louim commented 9 years ago

@danoc you're not alone. It's because giphy doesn't have access to the same amount of image that Google have. And they are often mislabeled.

But having it as an option is better than nothing at all.

gyoza commented 9 years ago

Here is another ghetto method that we've come up with..

We've setup 10 google search accounts and we've setup our hubot to restart every hour and switch to the next account...That gives you 1000 queries a day... That is a lot.. Ghetto fabulous, but requires no forking of the code and figuring image manipulation techniques etc..

RileyMills commented 9 years ago

@gyoza Ohhh that's an interesting idea. Would probably solve the issue for my team's needs. I might look into setting up a rotation for the accounts so that Hubot doesn't need to be restarted, but otherwise I think that'll work wonderfully.

liquidmetal commented 9 years ago

@gyoza @Sarkazein I could be wrong - but that probably violates the T&C of using the API.

RileyMills commented 9 years ago

Darn... should have thought of that. Oh well, we'll have to see how far 100 per day gets us.

HaroldPutman commented 9 years ago

Fixed in version 0.2.2 with PR #12

mbadura commented 9 years ago

Hi what value should HUBOT_GOOGLE_SAFE_SEARCH get ? '0' , 'off', 'false' is not working

HaroldPutman commented 9 years ago

The value of HUBOT_GOOGLE_SAFE_SEARCH is assigned to the "safe" parameter in the search request. If you are using the CSE API it can have a value of "high", "medium", or "off". If you are using the deprecated API it can have a value of "active", "moderate" or "off".

What makes you believe that "off" is not working?

mbadura commented 9 years ago

@HaroldPutman Thats my var config:

http://creativecast.de/mba/cs-hodor_·_Settings___Heroku_1BF23C25.png

And when i'm testing with f.e nude girl query it end up with different result than on google images search (with safesearch off)

HaroldPutman commented 9 years ago

Make sure you are running the latest code. This is a relatively new feature (v0.2.3). check node_modules/hubot-google-images/src/google-images.coffee and make sure you find HUBOT_GOOGLE_SAFE_SEARCH referenced in there.

If that is not the issue check the configuration of your Custom Search Engine.

I'm haven't tested this feature myself, but I assume it works for @taviscaron who submitted the PR.

On Tue, Nov 10, 2015 at 9:53 AM, Marek Badura notifications@github.com wrote:

@HaroldPutman https://github.com/HaroldPutman Thats my var config:

http://creativecast.de/mba/cs-hodor_·_Settings___Heroku_1BF23C25.png

And when i'm testing with f.e nude girl query it end up with different result than on google images search (with safesearch off)

— Reply to this email directly or view it on GitHub https://github.com/hubot-scripts/hubot-google-images/issues/10#issuecomment-155440834 .

Harold PUTMAN Web Technology Specialist

O +1 859 232 2839 M +1 859 904 9735 harold.putman@lexmark.com email@lexmark.com

http://www.lexmark.com/ www.lexmark.com

asenchuk commented 8 years ago

Confirm this. HUBOT_GOOGLE_SAFE_SEARCH=off works for both CSE and deprecated API

mbadura commented 8 years ago

@HaroldPutman : yes i'm running latest code

  q =
      q: query,
      searchType:'image',
      safe: process.env.HUBOT_GOOGLE_SAFE_SEARCH || 'high',

Can you tell me more about CSE settings ? I can see in developers console that its working. I user "Browser API Key" , maybe here's the issue ?

and

heroku config:get HUBOT_GOOGLE_SAFE_SEARCH
off

and output for nude girl: slack

newsroomdev commented 8 years ago

@HaroldPutman @alehandrof @jasonleibowitz

Followed your example above but I'm still getting an empty body object returned when making the request. The result is all requests default to this line of code, aka "Oops. I had trouble searching..."

My res.statusCode is still 200 though, and i'm using the latest version. Here's what the logs say

vocbot animate me trump
vocbot> [Tue Dec 08 2015 13:42:17 GMT-0800 (PST)] DEBUG Message 'vocbot animate me trump' matched regex //^\s*[@]?vocbot[:,]?\s*(?:animate( me)? (.+))/i/; listener.options = { id: null }
[Tue Dec 08 2015 13:42:17 GMT-0800 (PST)] DEBUG Executing listener callback for Message 'vocbot animate me trump'
[Tue Dec 08 2015 13:42:17 GMT-0800 (PST)] DEBUG Message 'vocbot animate me trump' matched regex //.*//; listener.options = { id: null }
[Tue Dec 08 2015 13:42:17 GMT-0800 (PST)] DEBUG Executing listener callback for Message 'vocbot animate me trump'
Oops. I had trouble searching 'trump'. Try later.
dmerrick commented 8 years ago

I'm experiencing the same thing as @geraldarthur. I followed the instructions, but every time I run "image me", Hubot says Oops. I had trouble searching 'foo'. Try later.

Pretorian commented 8 years ago

i'm getting results 4fold and sometimes timeouts, key and id are good.