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

Commit

Permalink
remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Dec 17, 2018
1 parent f685ad7 commit 4b1ba39
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 186 deletions.
269 changes: 134 additions & 135 deletions test/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,143 +11,142 @@ var subtitleFile = '1 1 1-179MiZSibco.en.vtt';
var thumbnailFile = 'Too Many Twists (Heist Night 5_5)-yy7EUIR0fic.jpg';

vows.describe('download').addBatch({
'a video with format specified': {
'topic': function() {
'use strict';
var dl = ytdl(video1, ['-f', '18']);
var cb = this.callback;

dl.on('error', cb);

dl.on('info', function(info) {
var pos = 0;
var progress;

dl.on('data', function(data) {
pos += data.length;
progress = pos / info.size;
});

dl.on('end', function() {
cb(null, progress, info);
});

var filepath = path.join(__dirname, info._filename);
dl.pipe(fs.createWriteStream(filepath));
});
},

'data returned': function(err, progress, data) {
'use strict';
if (err) { throw err; }

assert.equal(progress, 1);
assert.isObject(data);
assert.equal(data.id, '90AiXO1pAiA');
assert.isTrue(/lol-90AiXO1pAiA/.test(data._filename));
assert.equal(data.size, 755906);
},

'file was downloaded': function(err, progress, data) {
'use strict';
if (err) { throw err; }

// Check existance.
var filepath = path.join(__dirname, data._filename);
var exists = fs.existsSync(filepath);
if (exists) {
// Delete file after each test.
fs.unlinkSync(filepath);
} else {
assert.isTrue(exists);
}
}
'a video with format specified': {
'topic': function () {
'use strict';
var dl = ytdl(video1, ['-f', '18']);
var cb = this.callback;

dl.on('error', cb);

dl.on('info', function (info) {
var pos = 0;
var progress;

dl.on('data', function (data) {
pos += data.length;
progress = pos / info.size;
});

dl.on('end', function () {
cb(null, progress, info);
});

var filepath = path.join(__dirname, info._filename);
dl.pipe(fs.createWriteStream(filepath));
});
},
'a video with no format specified': {
'topic': function() {
'use strict';
var dl = ytdl(video3);
var cb = this.callback;

dl.on('error', cb);

dl.on('info', function(info) {
var pos = 0;
var progress;

dl.on('data', function(data) {
pos += data.length;
progress = pos / info.size;
});

dl.on('end', function() {
cb(null, progress, info);
});

var filepath = path.join(__dirname, info._filename);
dl.pipe(fs.createWriteStream(filepath));
});
},

'data returned': function(err, progress, data) {
'use strict';
if (err) { throw err; }

assert.equal(progress, 1);
assert.isObject(data);
assert.equal(data.id, 'AW8OOp2undg');
// assert.equal(data.size, 49550); // No relevant, can be change through time
},

'file was downloaded': function(err, progress, data) {
'use strict';
if (err) { throw err; }

// Check existance.
var filepath = path.join(__dirname, data._filename);
var exists = fs.existsSync(filepath);
if (exists) {
// Delete file after each test.
fs.unlinkSync(filepath);
} else {
assert.isTrue(exists);
}
}

'data returned': function (err, progress, data) {
'use strict';
if (err) { throw err; }

assert.equal(progress, 1);
assert.isObject(data);
assert.equal(data.id, '90AiXO1pAiA');
assert.isTrue(/lol-90AiXO1pAiA/.test(data._filename));
assert.equal(data.size, 755906);
},

'file was downloaded': function (err, progress, data) {
'use strict';
if (err) { throw err; }

// Check existance.
var filepath = path.join(__dirname, data._filename);
var exists = fs.existsSync(filepath);
if (exists) {
// Delete file after each test.
fs.unlinkSync(filepath);
} else {
assert.isTrue(exists);
}
}
},
'a video with no format specified': {
'topic': function () {
'use strict';
var dl = ytdl(video3);
var cb = this.callback;

dl.on('error', cb);

dl.on('info', function (info) {
var pos = 0;
var progress;

dl.on('data', function (data) {
pos += data.length;
progress = pos / info.size;
});

dl.on('end', function () {
cb(null, progress, info);
});

var filepath = path.join(__dirname, info._filename);
dl.pipe(fs.createWriteStream(filepath));
});
},

'data returned': function (err, progress, data) {
'use strict';
if (err) { throw err; }

assert.equal(progress, 1);
assert.isObject(data);
assert.equal(data.id, 'AW8OOp2undg');
},
'a video with subtitles': {
topic: function() {
'use strict';
try {
fs.unlinkSync(path.join(__dirname, subtitleFile));
} catch (err) {}
ytdl.getSubs(video2, { lang: 'en', cwd: __dirname }, this.callback);
},

'subtitles were downloaded': function(err, files) {
'use strict';
if (err) { throw err; }

assert.equal(files[0], subtitleFile);
assert.isTrue(fs.existsSync(path.join(__dirname, subtitleFile)));
fs.unlinkSync(path.join(__dirname, subtitleFile));
}

'file was downloaded': function (err, progress, data) {
'use strict';
if (err) { throw err; }

// Check existance.
var filepath = path.join(__dirname, data._filename);
var exists = fs.existsSync(filepath);
if (exists) {
// Delete file after each test.
fs.unlinkSync(filepath);
} else {
assert.isTrue(exists);
}
}
},
'a video with subtitles': {
topic: function () {
'use strict';
try {
fs.unlinkSync(path.join(__dirname, subtitleFile));
} catch (err) { }
ytdl.getSubs(video2, { lang: 'en', cwd: __dirname }, this.callback);
},

'subtitles were downloaded': function (err, files) {
'use strict';
if (err) { throw err; }

assert.equal(files[0], subtitleFile);
assert.isTrue(fs.existsSync(path.join(__dirname, subtitleFile)));
fs.unlinkSync(path.join(__dirname, subtitleFile));
}
},
'a video with thumbnail': {
topic: function () {
'use strict';
try {
fs.unlinkSync(path.join(__dirname, thumbnailFile));
} catch (err) { }
ytdl.getThumbs(video4, { cwd: __dirname }, this.callback);
},
'a video with thumbnail': {
topic: function() {
'use strict';
try {
fs.unlinkSync(path.join(__dirname, thumbnailFile));
} catch (err) {}
ytdl.getThumbs(video4, { cwd: __dirname }, this.callback);
},

'thumbnail was downloaded': function(err, files) {
'use strict';
if (err) { throw err; }

assert.equal(files[0], thumbnailFile);
assert.isTrue(fs.existsSync(path.join(__dirname, thumbnailFile)));
fs.unlinkSync(path.join(__dirname, thumbnailFile));
}

'thumbnail was downloaded': function (err, files) {
'use strict';
if (err) { throw err; }

assert.equal(files[0], thumbnailFile);
assert.isTrue(fs.existsSync(path.join(__dirname, thumbnailFile)));
fs.unlinkSync(path.join(__dirname, thumbnailFile));
}
}
}).export(module);
Loading

0 comments on commit 4b1ba39

Please sign in to comment.