diff options
author | przemyslawpluta <przemekpluta@hotmail.com> | 2014-06-16 00:39:59 +0100 |
---|---|---|
committer | przemyslawpluta <przemekpluta@hotmail.com> | 2014-06-16 00:39:59 +0100 |
commit | 3ac33dafa17ae9f072b70dd469141bd5f6de39cf (patch) | |
tree | 2559d7ea92166c18eb2cada9555f966b7b22ace4 /lib | |
parent | 1e4b910edd0c55f0332a9797c143dfa077aa31b4 (diff) | |
download | mongo-edu-3ac33dafa17ae9f072b70dd469141bd5f6de39cf.zip |
update
add --co option for ordered list dump
version dump
Diffstat (limited to 'lib')
-rw-r--r-- | lib/videos.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/videos.js b/lib/videos.js index f64d330..d4ce7b4 100644 --- a/lib/videos.js +++ b/lib/videos.js @@ -18,7 +18,7 @@ var path = require('path'), execFile = require('child_process').execFile, _ = require('lodash'); -var downloadPath = '', downloadList = [], ncc = false, handout = false, cc = false, uz = false, hq = false, isWin = /^win/.test(process.platform); +var downloadPath = '', downloadList = [], co = false, ncc = false, handout = false, cc = false, uz = false, hq = false, isWin = /^win/.test(process.platform); var setOptions = function setOptions(argv) { @@ -30,6 +30,7 @@ var setOptions = function setOptions(argv) { if (argv.cc) { cc = true; } if (argv.uz) { uz = true; } if (argv.hq) { hq = true; } + if (argv.co) { co = true; } }; var handleList = function handleList(list) { @@ -124,7 +125,7 @@ var handleList = function handleList(list) { var dl = youtubedl.download(item, downloadPath, opt), bar; dl.on('download', function download(data) { - downloadList.push(path.basename(data.filename)); + if (co) { downloadList.push(path.basename(data.filename)); } console.log('[' + 'i'.magenta + '] Downloading: ' + data.filename.cyan + ' > ' + item); bar = new ProgressBar('[' + '>'.green + '] ' + data.size + ' [:bar] :percent :etas', { complete: '=', incomplete: ' ', width: 20, total: 100.0 }); }); @@ -154,10 +155,14 @@ var handleList = function handleList(list) { if (currentList.length) { return getVideos(currentList.shift()); } - fs.writeFile(downloadPath + 'Course_Order.txt', downloadList.join((!isWin) ? '\n' : '\r\n'), function write(err) { - if (err !== null) { console.log(err.stack); } + if (co) { + fs.writeFile(downloadPath + 'Course_Order.txt', downloadList.join((!isWin) ? '\n' : '\r\n'), function write(err) { + if (err !== null) { console.log(err.stack); } + console.log('[ Finished ]'.green); + }); + } else { console.log('[ Finished ]'.green); - }); + } }; |