From 9964d3803e7fa3bc6823a755de8101cb02333def Mon Sep 17 00:00:00 2001 From: przemyslawpluta Date: Thu, 14 Jan 2016 18:45:04 +0000 Subject: download original subtitles fail to auto --- .resume/resume.js | 3 +++ lib/videos.js | 16 +++++++++++----- package.json | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.resume/resume.js b/.resume/resume.js index 385e356..6d6fa6b 100644 --- a/.resume/resume.js +++ b/.resume/resume.js @@ -305,6 +305,9 @@ ytdl.getSubs = function(url, options, callback) { if (options.lang) { args.push('--sub-lang=' + options.lang); } + if (!options.warrning) { + args.push('--no-warnings'); + } call(url, args, [], { cwd: options.cwd }, function(err, data) { if (err) return callback(err); diff --git a/lib/videos.js b/lib/videos.js index 0fe77b4..e737cab 100644 --- a/lib/videos.js +++ b/lib/videos.js @@ -152,17 +152,23 @@ var handleList = function handleList(list, tags) { }, - getSubtitles = function getSubtitles(item, left, currentList, tags) { + getSubtitles = function getSubtitles(item, left, currentList, tags, switchAuto) { if (!cc) { if (left) { console.log('i'.magenta + ' ' + left); } return handleList(currentList, tags); } - youtubedl.getSubs(item, { auto: true, all: false, lang: 'en', cwd: downloadPath }, function getSubs(err) { - if (err !== null) { - console.log('i'.red + ' Unable to download subtitles.'); + var subOptions = {auto: false, all: false, lang: 'en', cwd: downloadPath}, extraInfo = ''; + + if (switchAuto) { subOptions.auto = true; } + + youtubedl.getSubs(item, subOptions, function getSubs(err, files) { + if (!files.length || err) { + if (!subOptions.auto) { extraInfo = ' Switching to automated subtitles.'; } + console.log('i'.red + ' Unable to download subtitles.' + extraInfo); + if (extraInfo !== '') { return getSubtitles(item, left, currentList, tags, true); } } else { - console.log('i'.magenta + ' Subtitles downloaded.'); + console.log('i'.magenta + ' Subtitles ' + files.toString().cyan + ' downloaded.'); } if (left) { console.log('i'.magenta + ' ' + left); } handleList(currentList, tags); diff --git a/package.json b/package.json index 972ad06..804ce18 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mongo-edu", "preferGlobal": true, - "version": "0.2.52", + "version": "0.2.53", "author": "Przemyslaw Pluta (http://przemyslawpluta.com)", "description": "Select and download videos and handouts from university.mongodb.com courses", "main": "./mongo-edu", -- cgit v1.2.3