summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorprzemyslawpluta <przemekpluta@hotmail.com>2016-01-07 20:03:05 +0000
committerprzemyslawpluta <przemekpluta@hotmail.com>2016-01-07 20:03:05 +0000
commitdd2cf8bd5e90a01466a5934017e2129aeb2b0f51 (patch)
tree3759a0e9994d86eb301904e1bd93b5d5dac0dc78 /lib
parent617c52ba5f06bcb3f9a5100347253c7969317101 (diff)
downloadmongo-edu-dd2cf8bd5e90a01466a5934017e2129aeb2b0f51.zip
resume downlod
Diffstat (limited to 'lib')
-rw-r--r--lib/videos.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/videos.js b/lib/videos.js
index 0f58523..1dde7e1 100644
--- a/lib/videos.js
+++ b/lib/videos.js
@@ -177,12 +177,19 @@ var handleList = function handleList(list, tags) {
stash = info;
if (co) { downloadList.push({id: item, name: path.basename(info._filename)}); }
if (notAvailable) { console.log('i'.magenta + ' No HQ video available for ' + info.fulltitle.white.bold + ' trying default quality ...'); }
- console.log('i'.magenta + ((downloaded > 0) ? ' Resuming download: ' : ' Downloading: ') + info._filename.cyan + ' > ' + item);
- bar = new ProgressBar('>'.green + ' ' + filesize(info.size) + ' [:bar] :percent :etas', { complete: '=', incomplete: ' ', width: 20, total: parseInt(info.size, 10) });
+ console.log('i'.magenta + ((downloaded > 0) ? ' ' + 'Resuming download'.underline + ': ': ' Downloading: ') + info._filename.cyan + ' > ' + item);
+ bar = new ProgressBar('>'.green + ' ' + ((downloaded > 0) ? '[' + filesize(downloaded) + '] ' + filesize(info.size) : filesize(info.size)) + ' [:bar] :percent :etas', { complete: '=', incomplete: ' ', width: 20, total: parseInt(info.size, 10) });
console.time('i'.magenta + ' ' + info._filename + '. Done in');
dl.pipe(fs.createWriteStream(downloadPath + info._filename, {flags: 'a'}));
});
+ dl.on('complete', function(info) {
+ size = info.size + downloaded;
+ stash = info;
+ console.log('i'.magenta + ' File ' + stash._filename.green + ' already downloaded.');
+ console.time('i'.magenta + ' ' + info._filename + '. Done in');
+ });
+
dl.on('data', function(data) {
if (!bar.complete) { bar.tick(data.length); }
});
@@ -201,7 +208,7 @@ var handleList = function handleList(list, tags) {
});
dl.on('end', function end() {
- var left = (currentList.length)? currentList.length + ' left ...' : '';
+ var left = (currentList.length) ? currentList.length + ' left ...' : '';
console.timeEnd('i'.magenta + ' ' + stash._filename + '. Done in');
getSubtitles(item, left, currentList, tags);
});