summaryrefslogtreecommitdiff
path: root/lib/videos.js
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 /lib/videos.js
parenteeefcdad742f40a83d6677e8d1b90bcadaedee8d (diff)
downloadmongo-edu-725424153522edcca253203127defab8cb6174d8.zip
handle unavailable info
Diffstat (limited to 'lib/videos.js')
-rw-r--r--lib/videos.js9
1 files changed, 5 insertions, 4 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;