diff options
Diffstat (limited to 'lib/login.js')
-rw-r--r-- | lib/login.js | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/login.js b/lib/login.js index 2dd9bef..968b518 100644 --- a/lib/login.js +++ b/lib/login.js @@ -162,7 +162,7 @@ module.exports = { 'use strict'; - var videos = [], state = false, list, $, current; + var videos = [], list, $, current; if (argv.cw || argv.cwd) { return coursewareHandler.filterVideos(opt, host, jar, argv, callback); } @@ -178,24 +178,17 @@ module.exports = { current = list.find('code').text(); - if ((current.indexOf('http://') !== -1) || (current.indexOf('https://') !== -1)) { - videos = _.compact(current.split('\n')); - } + if (current.match(/http:\/\/|https:\/\//)) { videos = _.compact(current.split('\n')); } if (!videos.length) { list.children('p').children().each(function each(i, item) { - var current = $(item); - if (current.attr('href')) { - videos.push({ name: current.text().split('-')[0], value: current.attr('href') }); - } + var current = $(item), href = current.attr('href'); + if (href && href.match(/http:\/\/|https:\/\//)) { videos.push(href); } }); - - if (videos.length) { videos.unshift({name: 'All', value: 'all', checked: true}, {name: 'Cancel', value: 'cancel'}); } - state = true; } - return callback(null, videos, state); + return callback(null, videos); } callback(new Error(res.statusCode)); |