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

Commit

Permalink
Return the full info provided by youtube-dl
Browse files Browse the repository at this point in the history
Some entries are added/modified to keep backwards compatibility
  • Loading branch information
jaimeMF committed Feb 11, 2015
1 parent e93a8b9 commit ace1b11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
19 changes: 6 additions & 13 deletions lib/youtube-dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ function call(video, args1, args2, options, callback) {
*/
function filterData(data) {
var info = JSON.parse(data);
var format = info.format.split(' - ');
function formatDuration(duration) {
var parts = [];
parts.push(duration % 60);
Expand All @@ -179,18 +178,12 @@ function filterData(data) {
return parts.reverse().join(':');
}

return {
title : info.title,
id : info.id,
url : info.url,
thumbnail : info.thumbnail,
description : info.description,
filename : info._filename,
duration : formatDuration(info.duration),
itag : info.format_id,
resolution : format[1],
};

// Add and process some entries to keep backwards compatibility
info.filename = info._filename;
info.duration = formatDuration(info.duration);
info.itag = info.format_id;
info.resolution = info.format.split(' - ')[1];
return info;
}


Expand Down
3 changes: 3 additions & 0 deletions test/getInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ vows.describe('getInfo').addBatch({
assert.equal(info.filename, 'lol-90AiXO1pAiA.mp4');
assert.equal(info.resolution, '640x360');
assert.equal(info.duration, '12');
assert.equal(info.width, 640);
assert.equal(info.height, 360);
assert.isArray(info.formats);
}
},
'from a soundcloud track': {
Expand Down

0 comments on commit ace1b11

Please sign in to comment.