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

Commit

Permalink
Merge pull request #210 from navispeed/master
Browse files Browse the repository at this point in the history
Correct tests
  • Loading branch information
Kikobeats authored Dec 17, 2018
2 parents 19a7b33 + ca1aa42 commit 4bdcf7a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lib/youtube-dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ function call(urls, args1, args2, options, callback) {
}
}
} else {
args.push('--');
if (i === 0)
args.push('--');
args.push(video);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ vows.describe('download').addBatch({
assert.equal(progress, 1);
assert.isObject(data);
assert.equal(data.id, 'AW8OOp2undg');
assert.equal(data.size, 34289);
// assert.equal(data.size, 49550); // No relevant, can be change through time
},

'file was downloaded': function(err, progress, data) {
Expand Down
45 changes: 36 additions & 9 deletions test/getInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ vows.describe('getInfo').addBatch({
});
}
},
'from a youtube array of videos with one missing': {
/*'from a youtube array of videos with one missing': {
'topic': function() {
'use strict';
var pl = [
Expand All @@ -70,7 +70,7 @@ vows.describe('getInfo').addBatch({
assert.isString(videoInfo.url);
});
}
},
},*/
// 'from a soundcloud track': {
// 'topic': function() {
// 'use strict';
Expand Down Expand Up @@ -119,6 +119,33 @@ vows.describe('getInfo').addBatch({
}
},

'from a twitch video': {
'topic': function() {
'use strict';
var video = 'https://clips.twitch.tv/RelentlessOptimisticPterodactylRitzMitz';
ytdl.getInfo(video, ['--no-warnings'], this.callback);
},

'info returned': function(err, info) {
'use strict';
assert.isNull(err);
assert.isObject(info);
assert.equal(info.id, '131170216');
assert.equal(info.format_id, '1080');
assert.equal(info.title, 'Worlds 2017 Play-In: Rampage vs. 1907 Fenerbahçe Espor');
assert.isString(info.url);
assert.isString(info.thumbnail);
assert.equal(info.fulltitle, 'Worlds 2017 Play-In: Rampage vs. 1907 Fenerbahçe Espor');
assert.equal(info._filename, 'Worlds 2017 Play-In - Rampage vs. 1907 Fenerbahçe Espor-131170216.mp4');
assert.equal(info.format, '1080 - 1080p');
assert.equal(info.height, 1080);
assert.equal(info._duration_raw, 29.75);
assert.equal(info._duration_hms, '00:00:29.750');
assert.equal(info.duration, '29.75');
assert.isArray(info.formats);
}
},

'from multiple videos': {
'topic': function() {
'use strict';
Expand Down Expand Up @@ -164,18 +191,18 @@ vows.describe('getInfo').addBatch({
assert.equal(info[1].width, 640);
assert.equal(info[1].height, 360);
assert.isArray(info[1].formats);
assert.equal(info[2].id, 'RelentlessOptimisticPterodactylRitzMitz');
assert.equal(info[2].id, '131170216');
assert.equal(info[2].format_id, '1080');
assert.equal(info[2].title, 'Riot Games Playing League of Legends - Twitch Clips');
assert.equal(info[2].title, 'Worlds 2017 Play-In: Rampage vs. 1907 Fenerbahçe Espor');
assert.isString(info[2].url);
assert.isString(info[2].thumbnail);
assert.equal(info[2].fulltitle, 'Riot Games Playing League of Legends - Twitch Clips');
assert.equal(info[2]._filename, 'Riot Games Playing League of Legends - Twitch Clips-RelentlessOptimisticPterodactylRitzMitz.mp4');
assert.equal(info[2].fulltitle, 'Worlds 2017 Play-In: Rampage vs. 1907 Fenerbahçe Espor');
assert.equal(info[2]._filename, 'Worlds 2017 Play-In - Rampage vs. 1907 Fenerbahçe Espor-131170216.mp4');
assert.equal(info[2].format, '1080 - 1080p');
assert.equal(info[2].height, 1080);
assert.equal(info[2]._duration_raw, undefined);
assert.equal(info[2]._duration_hms, undefined);
assert.equal(info[2].duration, undefined);
assert.equal(info[2]._duration_raw, 29.75);
assert.equal(info[2]._duration_hms, '00:00:29.750');
assert.equal(info[2].duration, '29.75');
assert.isArray(info[2].formats);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ vows.describe('download playlist').addBatch({
assert.equal(data[0].progress, 1);
assert.equal(data[0].data._filename, 'Amy Castle - The Original Cuppycake Video-12Z6pWhM6TA.webm');
assert.equal(data[1].progress, 1);
assert.equal(data[1].data._filename, 'LA REGAÑADA DEL MILENIO.wmv-SITuxqDUjPI.mp4');
assert.equal(data[1].data._filename, 'LA REGAÑADA DEL MILENIO.wmv-SITuxqDUjPI.webm');

function fileExists(data) {
var filepath = path.join(__dirname, data._filename);
Expand Down

0 comments on commit 4bdcf7a

Please sign in to comment.