From 36e874150c75a2b488d22225f4e33ffab48bfaa7 Mon Sep 17 00:00:00 2001 From: Roly Fentanes Date: Sat, 18 Aug 2012 23:57:11 -0700 Subject: [PATCH] cleanup --- lib/youtube-dl.js | 18 +++++++++--------- scripts/download.js | 6 ++---- test/download.js | 1 + 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/youtube-dl.js b/lib/youtube-dl.js index 2e6bd9a..c7b65a4 100644 --- a/lib/youtube-dl.js +++ b/lib/youtube-dl.js @@ -10,7 +10,7 @@ var spawn = require('child_process').spawn // arguments we dont want users to use with youtube-dl // because they will break the module -badArgs = [ +var badArgs = [ '-h', '--help' , '-v', '--version' , '-U', '--update' @@ -98,22 +98,22 @@ var getHumanTime = function(ms) { str = ''; if (d > 0) { - str += "" + d + " day" + (d > 1 ? 's' : '') + ", "; + str += d + ' day' + (d > 1 ? 's' : '') + ', '; set = true; } if (set || h > 0) { - str += "" + h + " hour" + (h > 1 ? 's' : '') + ", "; + str += h + ' hour' + (h > 1 ? 's' : '') + ', '; set = true; } if (set || m > 0) { - str += "" + m + " minute" + (m > 1 ? 's' : '') + ", "; + str += m + ' minute' + (m > 1 ? 's' : '') + ', '; set = true; } if (set || s > 0) { - str += "" + s + " second" + (s > 1 ? 's' : '') + ", "; + str += s + ' second' + (s > 1 ? 's' : '') + ', '; } - return "" + str + ms + " ms"; + return str + ms + ' ms'; }; @@ -183,7 +183,7 @@ exports.download = function(url, dest, args) { emitter.emit('error', err); }); - youtubedl.on('exit', function(code) { + youtubedl.on('exit', function() { var averageSpeed = 0; for (var i = 0, len = speed.length; i < len; i++) { averageSpeed += speed[i]; @@ -223,12 +223,12 @@ exports.info = function(url, callback, args) { args.push(url); // call youtube-dl - var youtubedl = execFile(file, args, function(err, stdout, stderr) { + execFile(file, args, function(err, stdout, stderr) { if (err) return callback(err); if (stderr) return callback(new Error(stderr.slice(7))); var data = stdout.split('\n'); - info = { + var info = { title : data[0] , url : data[1] , thumbnail : data[2] diff --git a/scripts/download.js b/scripts/download.js index 99cf9ef..3078760 100644 --- a/scripts/download.js +++ b/scripts/download.js @@ -2,20 +2,18 @@ var fs = require('fs') , path = require('path') , existsSync = fs.existsSync || path.existsSync , https = require('https') - , exec = require('child_process').exec ; var dir = path.join(__dirname, '..', 'bin') , filename = 'youtube-dl' , filepath = path.join(dir, filename) - , n = 0 ; // make bin dir if it doesn't exists if (!existsSync(dir)) { - fs.mkdirSync(dir, 0744); + fs.mkdirSync(dir, 484); } // download latst version of youtube-dl @@ -30,7 +28,7 @@ https.get({ res.pipe(fs.createWriteStream(filepath)); res.on('end', function() { // make file executable - fs.chmodSync(filepath, 0711); + fs.chmodSync(filepath, 457); console.log('Finished!'); }); diff --git a/test/download.js b/test/download.js index 2ec18d2..a2c9497 100644 --- a/test/download.js +++ b/test/download.js @@ -21,6 +21,7 @@ vows.describe('download').addBatch({ }, 'data returned': function(err, data) { + assert.isObject(data); assert.include(data, 'filename'); assert.isString(data.filename); assert.include(data, 'size');