summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/initialize.js12
-rw-r--r--lib/login.js10
-rw-r--r--package.json2
3 files changed, 15 insertions, 9 deletions
diff --git a/lib/initialize.js b/lib/initialize.js
index 6adb6cd..9585859 100644
--- a/lib/initialize.js
+++ b/lib/initialize.js
@@ -57,13 +57,15 @@ module.exports = function run(profile, argv) {
function processList(data, profile) {
- if (data.length) {
+ if (!data.length) {
+ if (profile.noCourses) { return console.log('i'.red + ' ' + checkName(profile) + ' ' + profile.noCourses); }
+ return console.log('i'.red + ' ' + checkName(profile) + ' ' + 'Could not locate any courses in your profile. Have you registered already?\n');
+ }
- classes[0].message = checkName(profile) + ' . Found ' + data.length + ' Course'+ ((data.length > 1)? 's' : '') + '. Select:';
- classes[0].choices = data;
- return currentList();
+ classes[0].message = checkName(profile) + ' . Found ' + data.length + ' Course'+ ((data.length > 1)? 's' : '') + '. Select:';
+ classes[0].choices = data;
+ currentList();
- }
}
function currentList() {
diff --git a/lib/login.js b/lib/login.js
index 4715bc3..8091168 100644
--- a/lib/login.js
+++ b/lib/login.js
@@ -94,14 +94,16 @@ module.exports = {
request({ url: url + '/dashboard', jar: jar }, function get(err, res, body) {
if (err !== null) { return callback(err, null); }
+
bar.tick();
+
if (res.statusCode === 200) {
var list = [], $ = cheerio.load(body),
-
current = $('section.my-courses-courses').children(),
-
- link = $(current).filter('.media').children().find('h3').children();
+ link = $(current).filter('.media').children().find('h3').children(),
+ noCourses = $('section[class="empty-dashboard-message"]').text(),
+ findNewCourses = $('section[class="empty-dashboard-message"] a').attr('href');
bar.tick();
@@ -111,6 +113,8 @@ module.exports = {
bar.tick();
+ if (noCourses) { currentProfile.noCourses = noCourses.trim().split('\n').map(function items(item) { return item.replace(/ +/g, ' '); }).join('') + ' at ' + url + findNewCourses + '.\n'; }
+
callback(null, list, currentProfile);
}
diff --git a/package.json b/package.json
index 6266e9c..250c5db 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "mongo-edu",
"preferGlobal": true,
- "version": "0.2.16",
+ "version": "0.2.17",
"author": "Przemyslaw Pluta <przemyslawplutadev@gmail.com> (http://przemyslawpluta.com)",
"description": "Select and download videos and handouts from university.mongodb.com courses",
"main": "./mongo-edu",