From 725424153522edcca253203127defab8cb6174d8 Mon Sep 17 00:00:00 2001 From: przemyslawpluta Date: Sun, 10 Jan 2016 13:44:57 +0000 Subject: handle unavailable info --- lib/videos.js | 9 +++++---- package.json | 3 ++- 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 (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", -- cgit v1.2.3