From 5b0b52a39f86a9a22fb536545f48a9e7cf4af459 Mon Sep 17 00:00:00 2001 From: goferito Date: Wed, 10 Dec 2014 15:42:59 +0100 Subject: [PATCH 01/11] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f0bc3cd..9e5f857 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-bing-api", - "version": "0.1.6", + "version": "0.1.7", "description": "Node.js module for the Azure Bing Search API", "main": "index.js", "author": "Mr. Goferito", From 7133f9343eacc45ae9c5610e1c4d324b3bf7710c Mon Sep 17 00:00:00 2001 From: goferito Date: Wed, 4 Mar 2015 17:22:44 +0100 Subject: [PATCH 02/11] Add readme list of markets --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c979847..43ecb0a 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Bing.images("Ninja Turtles", function(error, res, body){ console.log(body); }, {top: 5, market: 'es-ES'}); ``` +[List of Bing Markets](https://msdn.microsoft.com/en-us/library/dd251064.aspx) ### License From 87650a37f6f409c0e102da0aba3aa7fd585a9f51 Mon Sep 17 00:00:00 2001 From: goferito Date: Sun, 8 Mar 2015 14:30:56 +0100 Subject: [PATCH 03/11] Alias Bing.search to Bing.web --- README.md | 2 +- lib/bing.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 43ecb0a..4614c52 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ var Bing = require('node-bing-api')({ accKey: "your-account-key" }); ##### Web Search: ```js -Bing.search("Pizza", function(error, res, body){ +Bing.web("Pizza", function(error, res, body){ console.log(body); }, { diff --git a/lib/bing.js b/lib/bing.js index f9c52e5..6237616 100644 --- a/lib/bing.js +++ b/lib/bing.js @@ -119,10 +119,14 @@ var Bing = function( options ) { * userAgent, reqTimeout, top, skip * @function */ -Bing.prototype.search = function(query, callback, options) { +Bing.prototype.web = function(query, callback, options) { this.searchVertical(query, "Web", callback, options); }; +// Alias Bing.search to Bing.web +// Note: Keep this for compatibility with older versions +Bing.prototype.search = Bing.prototype.web; + /** * Performs a Bing search in the Images vertical. From b46465fc2868f12a4c27510d1bc5c2e096ecbef2 Mon Sep 17 00:00:00 2001 From: goferito Date: Sun, 8 Mar 2015 15:12:26 +0100 Subject: [PATCH 04/11] Bump to version 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e5f857..3969b1f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-bing-api", - "version": "0.1.7", + "version": "1.0.0", "description": "Node.js module for the Azure Bing Search API", "main": "index.js", "author": "Mr. Goferito", From f1b36f21cfecbf0f1fef925776289c244b0b147f Mon Sep 17 00:00:00 2001 From: goferito Date: Sun, 8 Mar 2015 15:44:00 +0100 Subject: [PATCH 05/11] Add adult filter option --- README.md | 12 ++++++++++++ lib/bing.js | 1 + 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 4614c52..6d7b789 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,18 @@ Bing.images("Ninja Turtles", function(error, res, body){ [List of Bing Markets](https://msdn.microsoft.com/en-us/library/dd251064.aspx) +##### Adult Filter +```js +Bing.images('Kim Kardashian', function(error, res, body){ + console.log(body.d.results); +}, { market: 'en-US', adult: 'Strict'}); +``` +Accepted values: "Off", "Moderate", "Strict". + +*Moderate level should not include results with sexually explicit images +or videos, but may include sexually explicit text* + + ### License MIT diff --git a/lib/bing.js b/lib/bing.js index 6237616..04052a5 100644 --- a/lib/bing.js +++ b/lib/bing.js @@ -63,6 +63,7 @@ var Bing = function( options ) { + "&$top=" + opts.top + "&$skip=" + opts.skip + (opts.market ? "&Market=%27" + opts.market + "%27" : '') + + (opts.adult ? "&Adult=%27" + opts.adult + "%27" : '') + (opts.imagefilters ? '&' + qs.stringify({ "ImageFilters": "'" + opts.imagefilters + "'" }) : ''); From f51ba66e876b3a03ef3946c4d96f532f2535b225 Mon Sep 17 00:00:00 2001 From: goferito Date: Sun, 8 Mar 2015 15:46:23 +0100 Subject: [PATCH 06/11] Period --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d7b789..e3765da 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Bing.images('Kim Kardashian', function(error, res, body){ Accepted values: "Off", "Moderate", "Strict". *Moderate level should not include results with sexually explicit images -or videos, but may include sexually explicit text* +or videos, but may include sexually explicit text.* ### License From 4a8c33fb821e702040598b67a5d8116b0fe39400 Mon Sep 17 00:00:00 2001 From: goferito Date: Sun, 8 Mar 2015 15:58:22 +0100 Subject: [PATCH 07/11] Image filter values --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index e3765da..d0b33ef 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,15 @@ Bing.images("Ninja Turtles", function(error, res, body){ console.log(body); }, {imagefilters: 'Size:Small+Color:Monochrome'}); ``` +Accepted filter values: +* Size:\ +* Size:Height:\<*Height*\> +* Size:Width:\<*Width*\> +* Aspect:\ +* Color:\ +* Style:\ +* Face:\ + ##### Specify Market Getting spanish results: From 528694c07b6a490e3fcd73cc23ab8c55a2ebc33e Mon Sep 17 00:00:00 2001 From: goferito Date: Sun, 8 Mar 2015 16:07:05 +0100 Subject: [PATCH 08/11] Minor readme --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d0b33ef..afc93b2 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Node Bing API Node.js lib for the Azure Bing Web Search API -### Installation +## Installation ```` npm install node-bing-api ```` -### Usage +## Usage Require the library and initialialize it with your account key: @@ -14,7 +14,7 @@ Require the library and initialialize it with your account key: var Bing = require('node-bing-api')({ accKey: "your-account-key" }); ``` -##### Web Search: +#### Web Search: ```js Bing.web("Pizza", function(error, res, body){ console.log(body); @@ -25,7 +25,7 @@ Bing.web("Pizza", function(error, res, body){ }); ``` -##### Images Search: +#### Images Search: ```js Bing.images("Ninja Turtles", function(error, res, body){ console.log(body); @@ -47,7 +47,7 @@ Accepted filter values: * Face:\ -##### Specify Market +#### Specify Market Getting spanish results: ```js Bing.images("Ninja Turtles", function(error, res, body){ @@ -57,7 +57,7 @@ Bing.images("Ninja Turtles", function(error, res, body){ [List of Bing Markets](https://msdn.microsoft.com/en-us/library/dd251064.aspx) -##### Adult Filter +#### Adult Filter ```js Bing.images('Kim Kardashian', function(error, res, body){ console.log(body.d.results); @@ -69,6 +69,6 @@ Accepted values: "Off", "Moderate", "Strict". or videos, but may include sexually explicit text.* -### License +## License MIT From 5fc630c0043f219d20229b3737d3a170009ab720 Mon Sep 17 00:00:00 2001 From: goferito Date: Sun, 8 Mar 2015 16:08:13 +0100 Subject: [PATCH 09/11] Bump to 1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3969b1f..3f01888 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-bing-api", - "version": "1.0.0", + "version": "1.1.0", "description": "Node.js module for the Azure Bing Search API", "main": "index.js", "author": "Mr. Goferito", From 670105f579342e93ba8c189fada688eb178046df Mon Sep 17 00:00:00 2001 From: ray Date: Fri, 13 Mar 2015 15:13:35 +0100 Subject: [PATCH 10/11] improve image search use object instead of a string for the imagefilters --- README.md | 8 +++++++- lib/bing.js | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index afc93b2..fd3cc38 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,13 @@ Adding filter(s) for the Image Search ```js Bing.images("Ninja Turtles", function(error, res, body){ console.log(body); -}, {imagefilters: 'Size:Small+Color:Monochrome'}); + }, + { + imagefilters: { + size: 'small', + color: 'monochrome' + } + }); ``` Accepted filter values: * Size:\ diff --git a/lib/bing.js b/lib/bing.js index 04052a5..df26386 100644 --- a/lib/bing.js +++ b/lib/bing.js @@ -139,13 +139,29 @@ Bing.prototype.search = Bing.prototype.web; * * @param {Object} options Options to command, allows overriding of * rootUri, accKey (Bing API key), - * userAgent, reqTimeout, top, skip + * userAgent, reqTimeout, top, skip, + * imagefilters * @function */ Bing.prototype.images = function(query, callback, options) { + if (options.imagefilters) { + var filterQuery = ''; + var filters = Object.keys(options.imagefilters); + filters.map(function(key, i) { + filterQuery += capitalizeFirstLetter(key) + ':'; + filterQuery += capitalizeFirstLetter(options.imagefilters[key]); + if (i < filters.length - 1) + filterQuery += '+'; + }); + options.imagefilters = filterQuery; + } this.searchVertical(query, "Image", callback, options); }; +function capitalizeFirstLetter(s) { + return s.charAt(0).toUpperCase() + s.slice(1); +} + module.exports = Bing; From b752fcd12e8b9f04358b0fda03d2f3fbc4e0106d Mon Sep 17 00:00:00 2001 From: ray Date: Fri, 13 Mar 2015 15:22:08 +0100 Subject: [PATCH 11/11] fix missing options bug --- lib/bing.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/bing.js b/lib/bing.js index df26386..41ce18f 100644 --- a/lib/bing.js +++ b/lib/bing.js @@ -144,7 +144,7 @@ Bing.prototype.search = Bing.prototype.web; * @function */ Bing.prototype.images = function(query, callback, options) { - if (options.imagefilters) { + if (options && options.imagefilters) { var filterQuery = ''; var filters = Object.keys(options.imagefilters); filters.map(function(key, i) { @@ -162,6 +162,5 @@ function capitalizeFirstLetter(s) { return s.charAt(0).toUpperCase() + s.slice(1); } - module.exports = Bing;