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

Commit

Permalink
download first if array of clips
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslawpluta committed Apr 6, 2014
1 parent 8704b8e commit 28ed6bb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/youtube-dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ var ytdl = module.exports = function(url, args) {
return;
}

var req = request(data.url);
var item = (!data.length) ? data.url : data.shift();

var req = request(item.url);
req.on('response', function(res) {
if (res.statusCode !== 200) {
stream.emit('error', new Error('status code ' + res.statusCode));
return;
}

data.size = parseInt(res.headers['content-length'], 10);
stream.emit('info', data);
item.size = parseInt(res.headers['content-length'], 10);
stream.emit('info', item);
});
stream.resolve(req);
});
Expand Down

0 comments on commit 28ed6bb

Please sign in to comment.