summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorprzemyslawpluta <przemekpluta@hotmail.com>2014-09-24 21:41:06 +0100
committerprzemyslawpluta <przemekpluta@hotmail.com>2014-09-24 21:41:06 +0100
commite951065d894ebda590f2e636b3ee40b365de4266 (patch)
tree92211b15fb0fa04ddb6569fc7ea9868350b557b4 /lib
parenta21a4b3a7c2ef621899ff10f88cfcc50644a1514 (diff)
downloadmongo-edu-e951065d894ebda590f2e636b3ee40b365de4266.zip
update
redirection fix cleanup
Diffstat (limited to 'lib')
-rw-r--r--lib/configure.js2
-rw-r--r--lib/courseware.js4
-rw-r--r--lib/login.js4
-rw-r--r--lib/videos.js26
4 files changed, 18 insertions, 18 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) {