From dd2cf8bd5e90a01466a5934017e2129aeb2b0f51 Mon Sep 17 00:00:00 2001 From: przemyslawpluta Date: Thu, 7 Jan 2016 20:03:05 +0000 Subject: resume downlod --- .resume/resume.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to '.resume/resume.js') diff --git a/.resume/resume.js b/.resume/resume.js index 5d92f51..385e356 100644 --- a/.resume/resume.js +++ b/.resume/resume.js @@ -60,9 +60,15 @@ var ytdl = module.exports = function(videoUrl, args, options) { }); req.on('response', function(res) { - if (options && options.start > 0 && res.statusCode == 416) { + + var size = parseInt(res.headers['content-length'], 10); + if (size) { + item.size = size; + } + + if (options && options.start > 0 && res.statusCode === 416) { // the file that is being resumed is complete. - stream.emit('end'); + stream.emit('complete', item); return; } @@ -71,11 +77,8 @@ var ytdl = module.exports = function(videoUrl, args, options) { return; } - var size = parseInt(res.headers['content-length'], 10); - if (size) { - item.size = size; - } stream.emit('info', item); + }); stream.resolve(req); }); -- cgit v1.2.3