diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/videos.js | 13 |
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); }); |