diff options
-rw-r--r-- | lib/configure.js | 2 | ||||
-rw-r--r-- | lib/courseware.js | 4 | ||||
-rw-r--r-- | lib/login.js | 4 | ||||
-rw-r--r-- | lib/videos.js | 26 | ||||
-rw-r--r-- | mongo-edu.js | 6 | ||||
-rw-r--r-- | package.json | 10 |
6 files changed, 26 insertions, 26 deletions
diff --git a/lib/configure.js b/lib/configure.js index 670ede7..76a2bdd 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -45,7 +45,7 @@ module.exports = function configure(argv, callback) { } function failNoPython() { - console.log('[' + 'i'.red + '] Can\'t find Python executable ' + python.red + '. Check if Python installed ... if so set the ' + 'PYTHON'.green + ' env variable.'); + console.log('i'.red + ' Can\'t find Python executable ' + python.red + '. Check if Python installed ... if so set the ' + 'PYTHON'.green + ' env variable.'); process.exit(0); } diff --git a/lib/courseware.js b/lib/courseware.js index 1a8c0fb..82a1e1b 100644 --- a/lib/courseware.js +++ b/lib/courseware.js @@ -26,7 +26,7 @@ function saveData(argv, details, data, callback) { fs.writeFile(argv.d + details[0] + '-' + details[1] + '.txt', data.join((!isWin) ? '\n' : '\r\n'), function write(err) { if (err !== null) { return console.log(err.stack); } - console.log('[' + '>'.magenta + '] Video list generated with ' + data.length + ' item' + ((data.length > 1)? 's.' : '.')); + console.log('>'.magenta + ' Video list generated with ' + data.length + ' item' + ((data.length > 1)? 's.' : '.')); inquirer.prompt({type: 'confirm', name: 'download', message: 'Select and download?'}, function prompt(answers) { if (answers.download) { return callback(null, data); } @@ -120,7 +120,7 @@ module.exports = { if (!opt.url.stack) { return callback(null, []); } - var bar = new ProgressBar('[' + '>'.magenta + '] Searching Courseware [:bar] :percent', { complete: '=', incomplete: ' ', width: 20, total: opt.url.stack.length }), + var bar = new ProgressBar('>'.magenta + ' Searching Courseware [:bar] :percent', { complete: '=', incomplete: ' ', width: 20, total: opt.url.stack.length }), getPage = getDetails(jar, opt.url.stack.length, bar, opt.url.master, argv, callback), i; for (i = 0; i < opt.url.stack.length; i++) { diff --git a/lib/login.js b/lib/login.js index 968b518..d7f3fdf 100644 --- a/lib/login.js +++ b/lib/login.js @@ -29,7 +29,7 @@ module.exports = { 'use strict'; var url = host, - bar = new ProgressBar('[' + '>'.magenta + '] Searching [:bar] :percent', { complete: '=', incomplete: ' ', width: 20, total: 5 }), + bar = new ProgressBar('>'.magenta + ' Searching [:bar] :percent', { complete: '=', incomplete: ' ', width: 20, total: 5 }), CSRFTokenCookie = '', login = function login(token) { @@ -111,7 +111,7 @@ module.exports = { 'use strict'; - request({ url: opt.url, jar: jar }, function get(err, res, body) { + request({ url: opt.url, jar: jar, headers: { 'Referer' : opt.url.replace('course_wiki', 'syllabus'), }}, function get(err, res, body) { if (err !== null) { return callback(err, null); } if (res.statusCode === 404) { return callback(null, [], true); } diff --git a/lib/videos.js b/lib/videos.js index 19f1730..d8c9062 100644 --- a/lib/videos.js +++ b/lib/videos.js @@ -70,10 +70,10 @@ var handleList = function handleList(list, tags) { dlh = progress(request(item), { throttle: 0 }); - console.log('[' + 'i'.magenta + '] Downloading: ' + name.cyan); + console.log('i'.magenta + ' Downloading: ' + name.cyan); dlh.on('progress', function(state) { - if (!bar) { bar = new ProgressBar('[' + '>'.green + '] ' + filesize(state.total) + ' [:bar] :percent :etas', { complete: '=', incomplete: ' ', width: 20, total: 100 }); } + if (!bar) { bar = new ProgressBar('>'.green + ' ' + filesize(state.total) + ' [:bar] :percent :etas', { complete: '=', incomplete: ' ', width: 20, total: 100 }); } if (!bar.complete && progressSoFar !== state.percent) { var i; for (i = 0; i < (state.percent - hold); i++) { bar.tick(); } @@ -93,19 +93,19 @@ var handleList = function handleList(list, tags) { extname = path.extname(name); if (!uz || (extname !== '.zip')) { - console.log('[' + 'i'.green + '] Done.' + left); + console.log('i'.green + ' Done.' + left); return nextItem(currentList); } unzipFile = fs.createReadStream(downloadPath + name).pipe(unzip.Extract({ path: downloadPath + path.basename(name, extname) })); unzipFile.on('error', function error() { - console.log('[' + 'i'.red + '] Unable to unzip ' + name.red + ' try manually.'); + console.log('i'.red + ' Unable to unzip ' + name.red + ' try manually.'); rimraf(downloadPath + name.replace('.zip', ''), function rf() { nextItem(currentList); }); }); unzipFile.on('close', function close() { - console.log('[' + 'i'.green + '] Done.' + left); + console.log('i'.green + ' Done.' + left); cleanup(downloadPath + name, currentList); }); @@ -131,7 +131,7 @@ var handleList = function handleList(list, tags) { left = (currentList.length)? ' ' + currentList.length + ' left ...' : ''; if (exists) { - console.log('[' + '>'.magenta + '] ' + name + ' has already been downloaded.' + left); + console.log('>'.magenta + ' ' + name + ' has already been downloaded.' + left); return handleList(currentList); } @@ -151,9 +151,9 @@ var handleList = function handleList(list, tags) { size = info.size; stash = info; if (co) { downloadList.push({id: item, name: path.basename(info.filename)}); } - console.log('[' + 'i'.magenta + '] Downloading: ' + info.filename.cyan + ' > ' + item); - bar = new ProgressBar('[' + '>'.green + '] ' + filesize(size) + ' [:bar] :percent :etas', { complete: '=', incomplete: ' ', width: 20, total: parseInt(size, 10) }); - console.time('[' + 'i'.magenta + '] ' + info.filename + '. Done in'); + console.log('i'.magenta + ' Downloading: ' + info.filename.cyan + ' > ' + item); + bar = new ProgressBar('>'.green + ' ' + filesize(size) + ' [:bar] :percent :etas', { complete: '=', incomplete: ' ', width: 20, total: parseInt(size, 10) }); + console.time('i'.magenta + ' ' + info.filename + '. Done in'); dl.pipe(fs.createWriteStream(downloadPath + info.filename)); }); @@ -163,7 +163,7 @@ var handleList = function handleList(list, tags) { dl.on('error', function error(err) { if (err.message.indexOf('video doesn\'t have subtitles') !== -1) { - console.log('[' + 'i'.magenta + '] No Closed Captions Available For: ' + stash.filename.cyan + ' > ' + item); + console.log('i'.magenta + ' No Closed Captions Available For: ' + stash.filename.cyan + ' > ' + item); return getVideos(item, _.without(opt, '--write-sub', '--srt-lang=en')); } console.log(err.stack); @@ -171,8 +171,8 @@ var handleList = function handleList(list, tags) { dl.on('end', function end() { var left = (currentList.length)? currentList.length + ' left ...' : ''; - console.timeEnd('[' + 'i'.magenta + '] ' + stash.filename + '. Done in'); - if (left) { console.log('[' + 'i'.magenta + '] ' + left); } + console.timeEnd('i'.magenta + ' ' + stash.filename + '. Done in'); + if (left) { console.log('i'.magenta + ' ' + left); } handleList(currentList, tags); }); }; @@ -203,7 +203,7 @@ module.exports = { setOptions(argv); - var bar = new ProgressBar('[' + '>'.magenta + '] Collecting [:bar] :percent', { complete: '=', incomplete: ' ', width: 20, total: opt.length }), + var bar = new ProgressBar('>'.magenta + ' Collecting [:bar] :percent', { complete: '=', incomplete: ' ', width: 20, total: opt.length }), options = (!ncc) ? [] : ['--no-check-certificate']; var isFinished = function isFinished(count, items) { diff --git a/mongo-edu.js b/mongo-edu.js index 15b2db5..7a7dc6d 100644 --- a/mongo-edu.js +++ b/mongo-edu.js @@ -91,11 +91,11 @@ exports.create = function start() { return currentVideos(); } else { - if (pass) { return console.log('[' + 'i'.red + '] Looks like the course is not yet available or has already ended. ' + + if (pass) { return console.log('i'.red + ' Looks like the course is not yet available or has already ended. ' + lookFor + ' list is not available.\n\nCheck the start/end date for selected course.\n'); } } - return console.log('[' + 'i'.red + '] Unable to locate any ' + lookFor.toLowerCase() + ' lists in the wiki. Are ' + + return console.log('i'.red + ' Unable to locate any ' + lookFor.toLowerCase() + ' lists in the wiki. Are ' + lookFor.toLowerCase() + ' list present in the wiki?' + ((lookFor === 'Videos') ? ' Try to add ' + '--cw'.green + ' to switch and search on courseware instead.' : '')); }); @@ -129,7 +129,7 @@ exports.create = function start() { } - console.log('[' + 'i'.red + '] Could not locate any ' + lookFor.toLowerCase() + '.'); process.exit(0); + console.log('i'.red + ' Could not locate any ' + lookFor.toLowerCase() + '.'); process.exit(0); } }); diff --git a/package.json b/package.json index c645ae0..3a6a505 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mongo-edu", "preferGlobal": true, - "version": "0.1.35", + "version": "0.1.36", "author": "Przemyslaw Pluta <przemyslawplutadev@gmail.com> (http://przemyslawpluta.com)", "description": "Select and download videos and handouts from university.mongodb.com courses", "main": "./mongo-edu", @@ -33,8 +33,8 @@ "cheerio": "~0.17.0", "colors": "~0.6.2", "filesize": "~2.0.3", - "glob": "~4.0.5", - "inquirer": "~0.7.1", + "glob": "~4.0.6", + "inquirer": "~0.7.3", "lodash": "~2.4.1", "mkdirp": "~0.5.0", "mv": "~2.0.3", @@ -43,9 +43,9 @@ "request": "~2.42.0", "request-progress": "~0.3.1", "rimraf": "~2.2.8", - "unzip": "^0.1.11", + "unzip": "~0.1.11", "which": "~1.0.5", - "youtube-dl": "~1.5.13" + "youtube-dl": "~1.5.14" }, "engines": { "node": ">= 0.8.x" |