hubot-archive / hubot-google-images

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

Support for Google Custom Search Engine API #3

Closed HaroldPutman closed 9 years ago

HaroldPutman commented 9 years ago

If you set keys in the environment variables it will use your custom search engine. Other wise it uses the old API.

Note that the old Google search API has "safe=active" which is less restrictive than "safe=strict" on the new API. This can prevent some NSFW images which sneak through with the old API.

technicalpickles commented 9 years ago

It is a little bit confusing reading through the code. Do you think it'd be easier to read through if you have two different code paths for the custom search API vs the old one? I think it'd make the code simpler, and you can decide between them by checking for the environment variable.

HaroldPutman commented 9 years ago
HaroldPutman commented 9 years ago

Oh yeah, I also changed the old API to use https: instead of http:. That helps some of us running behind corporate firewalls, since those requests don't need to be proxied. I don't think it will have any negative impact on others.

technicalpickles commented 9 years ago

@HaroldPutman left some more feedback for you. Aside from that, I was wondering if you could make a note in the README why you would want to use this? Just worried it'd become a hidden, undocumented feature.

HaroldPutman commented 9 years ago

@technicalpickles Thanks for the excellent feedback. I'll update the code in a bit.

technicalpickles commented 9 years ago

@HaroldPutman how did you create your Custom Search Engine? I tried using the web interface, but I don't see anywhere to turn on safe search. I see you can use an XML API for creating it though, and there is a safe option there.

HaroldPutman commented 9 years ago

@technicalpickles, I created mine through the web UI. The safe part is hardcoded into the script when we build the query request with safe:'high'. I considered adding step by step instructions on creating the custom engine, but that is likely to get out of date.

technicalpickles commented 9 years ago

I released this in v0.2.0

@HaroldPutman it's been awhile, so you might not be interested it in anymore, but I've added you as a collaborator. If you send me your npm username, I can add you to be able to release it. I would suggest still using PRs for feedback. I do try to use semantic versioning for scripts. You can release with grunt release:<patch|minor|major>. Keep in mind it's a default script so anyone starting with hubot sees it :grin: