Permalink
Browse files

cleanup

  • Loading branch information...
1 parent fc09348 commit 36e874150c75a2b488d22225f4e33ffab48bfaa7 @fent committed Aug 19, 2012
Showing with 12 additions and 13 deletions.
  1. +9 −9 lib/youtube-dl.js
  2. +2 −4 scripts/download.js
  3. +1 −0 test/download.js
View
18 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]
View
6 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!');
});
View
1 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');

0 comments on commit 36e8741

Please sign in to comment.