summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprzemyslawpluta <przemekpluta@hotmail.com>2016-01-10 13:44:57 +0000
committerprzemyslawpluta <przemekpluta@hotmail.com>2016-01-10 13:44:57 +0000
commit725424153522edcca253203127defab8cb6174d8 (patch)
treeb9c6bdb341841d4c763ab891b7c7461eab1fadf5
parenteeefcdad742f40a83d6677e8d1b90bcadaedee8d (diff)
downloadmongo-edu-725424153522edcca253203127defab8cb6174d8.zip
handle unavailable info
-rw-r--r--lib/videos.js9
-rw-r--r--package.json3
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/videos.js b/lib/videos.js
index 33df751..9c90f92 100644
--- a/lib/videos.js
+++ b/lib/videos.js
@@ -18,7 +18,8 @@ var path = require('path'),
rimraf = require('rimraf'),
mv = require('mv'),
_ = require('lodash'),
- moment = require('moment');
+ moment = require('moment'),
+ getYouTubeID = require('get-youtube-id');
var isDebug = /[debug]/, downloadPath = '', proxy = '', downloadList = [], hash = {},
co = false, ncc = false, handout = false, cc = false, uz = false, hq = false, verbose = false, retry = 10, maxRetry;
@@ -287,11 +288,11 @@ module.exports = {
youtubedl.getInfo(item, options, function(err, info) {
- if (verbose && isDebug.test(err)) { console.log(err); }
+ if (verbose && isDebug.test(err)) { console.log('i'.red + ' Get Info Failed: '.red + err.stack); }
- hash[item] = info._filename;
+ hash[item] = (!err && info) ? info._filename : getYouTubeID(item);
- items.push((!err)?{name: info.fulltitle + ' - ' + info.width + 'x' + info.height, value: item, id: i}:{name: 'No info: ' + item, value: item, id: i});
+ items.push((!err && info)?{name: info.fulltitle + ' - ' + info.width + 'x' + info.height, value: item, id: i}:{name: 'No info: ' + item, value: item, id: i});
count = count - 1;
diff --git a/package.json b/package.json
index dd7d9b1..c1dc09f 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "mongo-edu",
"preferGlobal": true,
- "version": "0.2.51",
+ "version": "0.2.52",
"author": "Przemyslaw Pluta <przemyslawplutadev@gmail.com> (http://przemyslawpluta.com)",
"description": "Select and download videos and handouts from university.mongodb.com courses",
"main": "./mongo-edu",
@@ -36,6 +36,7 @@
"easy-table": "~1.0.0",
"extract-zip": "~1.4.0",
"filesize": "~3.1.5",
+ "get-youtube-id": "~1.0.0",
"glob": "~6.0.3",
"inquirer": "~0.11.1",
"lodash": "~3.10.1",