Permalink
Browse files

cleanup

  • Loading branch information...
fent committed Aug 19, 2012
1 parent 9001bd5 commit 5e913b6473c1c4e476c431faf8136fb0485b239d
Showing with 9 additions and 11 deletions.
  1. +9 −11 lib/index.js
View
@@ -41,7 +41,7 @@ function ytdl(link, options) {
if (cache.exists(id)) {
var info = cache.get(id);
process.nextTick(function() {
- download(link, options, stream, info);
+ download(options, stream, info);
});
} else {
@@ -52,7 +52,7 @@ function ytdl(link, options) {
return;
}
- download(link, options, stream, info);
+ download(options, stream, info);
});
}
@@ -63,13 +63,12 @@ function ytdl(link, options) {
/**
* Downloads a video.
*
- * @param (string) link
* @param (Object) options
* @param (ReadableStream) stream
* @param (Object) info
* @return (ReadableStream)
*/
-function download(link, options, stream, info) {
+function download(options, stream, info) {
var formats = info.formats;
if (options.filter) {
formats = formats.filter(options.filter);
@@ -148,11 +147,10 @@ ytdl.getInfo = function getInfo(link, requestOptions, callback) {
return callback(new Error('Video not found: ' + url));
}
- var info = { id: id };
var info = qs.parse(body);
if (info.status === 'fail') {
- callback(new Error('Error ' + info.errorcode + ': ' + info.reason));;
+ callback(new Error('Error ' + info.errorcode + ': ' + info.reason));
return;
}
@@ -163,9 +161,9 @@ ytdl.getInfo = function getInfo(link, requestOptions, callback) {
});
// convert some strings to javascript numbers and booleans
- info = Hash.map(info, function(val, key) {
- var intVal = parseInt(val);
- var floatVal = parseFloat(val);
+ info = Hash.map(info, function(val) {
+ var intVal = parseInt(val, 10);
+ var floatVal = parseFloat(val, 10);
if (intVal.toString() === val) {
return intVal;
@@ -226,13 +224,13 @@ ytdl.getInfo = function getInfo(link, requestOptions, callback) {
.slice(1, -1)
.split(', ')
.filter(function(val) { return val !== ''; })
- .map(function(val) { return parseInt(val); })
+ .map(function(val) { return parseInt(val, 10); })
;
cache.set(id, info);
callback(null, info);
});
-}
+};
/**

0 comments on commit 5e913b6

Please sign in to comment.