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 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/videos.js') 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; -- cgit v1.2.3