Permalink
Browse files

Fix max results parameter bug

  • Loading branch information...
1 parent 1b3c60f commit 1f1af49340a2c7dadff8a75c65942f04bbd4c8f9 @jlafitte committed Oct 30, 2013
Showing with 4 additions and 3 deletions.
  1. +2 −2 api.js
  2. +2 −1 package.json
View
4 api.js
@@ -24,7 +24,6 @@ exports["custom"] = {
params.url = "http://gdata.youtube.com/feeds/api/videos?v=2";
// Ensure we have a number to perform calculation.
var maxResults = parseInt(params['max-results']) || 50;
- if (maxResults > 50) params['max-results'] = "50";
var pages = Math.floor((maxResults-1)/50) + 1;
var startIndices = [];
// Prep an array for starting indices to use with `async.concat`
@@ -35,7 +34,8 @@ exports["custom"] = {
async.concat(startIndices, function (startIndex, callback) {
var shadowed = _.clone(params);
- shadowed['start-index'] = startIndex+'';
+ shadowed['max-results'] = maxResults >= 50 ? '50' : maxResults.toString(10);
+ shadowed['start-index'] = startIndex.toString(10);
spashttp.request(shadowed, credentials, function ( err, videos ) {
if (_.has(videos, 'feed')) {
View
@@ -22,7 +22,8 @@
"dependencies": {
"request": "2.x.x",
"underscore": "1.x.x",
- "async": "0.2.5"
+ "async": "0.2.5",
+ "spas-http": "0.1.x"
},
"main": "./api.js",
"engines": {

1 comment on commit 1f1af49

dtex commented on 1f1af49 Oct 30, 2013

Thank you!

Please sign in to comment.