From c9c95c52d4265f0bd8925946f43668a2d07cc41d Mon Sep 17 00:00:00 2001 From: przemyslawpluta Date: Mon, 17 Feb 2014 18:43:58 +0000 Subject: py3.x opt added --- lib/videos.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'lib/videos.js') diff --git a/lib/videos.js b/lib/videos.js index 44bfd7e..5eb21d2 100644 --- a/lib/videos.js +++ b/lib/videos.js @@ -11,15 +11,16 @@ var youtubedl = require('youtube-dl'), colors = require('colors'), _ = require('lodash'); -var downloadPath = ''; +var downloadPath = '', ncc = false; var handleList = function handleList(list) { var currentList = list, + opt = (!ncc) ? ['--max-quality=18'] : ['--max-quality=18', '--no-check-certificate']; getVideos = function getVideos(item) { - var dl = youtubedl.download(item, downloadPath, ['--max-quality=18']), bar; + var dl = youtubedl.download(item, downloadPath, opt), bar; dl.on('download', function(data) { console.log('[' + 'i'.magenta + '] Downloading: ' + data.filename.cyan + ' > ' + item); @@ -57,14 +58,19 @@ var handleList = function handleList(list) { module.exports = { - details: function details(opt, callback) { + details: function details(opt, argv, callback) { - var bar = new ProgressBar('[' + '>'.magenta + '] Collecting [:bar] :percent', { complete: '=', incomplete: ' ', width: 20, total: opt.length }); + downloadPath = argv.d; + if (argv.ncc) { ncc = true; } + + var bar = new ProgressBar('[' + '>'.magenta + '] Collecting [:bar] :percent', { complete: '=', incomplete: ' ', width: 20, total: opt.length }), + options = (!ncc) ? [] : ['--no-check-certificate']; var getDetails = function getDetails(item, i) { function getInfo() { - youtubedl.getInfo(item, function(err, info) { + + youtubedl.getInfo(item, options, function(err, info) { items.push((!err)?{name: info.title + ' - ' + info.resolution, value: item, id: i}:{name: 'No info: ' + item, value: item, id: i}); @@ -97,12 +103,10 @@ module.exports = { } }, - download: function download(opt, list, argv) { + download: function download(opt, list) { var options = opt.videos, fullList = [], selected = []; - downloadPath = argv.d; - if (options.length === 1 && options[0] === 'cancel') { return console.log('Cancel'); } if (options.length === 1 && options[0] === 'all') { -- cgit v1.2.3