Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed Aug 19, 2012
1 parent fc09348 commit 36e8741
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
18 changes: 9 additions & 9 deletions lib/youtube-dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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';
};


Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 2 additions & 4 deletions scripts/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!');
});

Expand Down
1 change: 1 addition & 0 deletions test/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 36e8741

Please sign in to comment.