summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprzemyslawpluta <przemekpluta@hotmail.com>2016-01-14 18:45:04 +0000
committerprzemyslawpluta <przemekpluta@hotmail.com>2016-01-14 18:45:04 +0000
commit9964d3803e7fa3bc6823a755de8101cb02333def (patch)
tree9b31c165ab848c62fb94a43c6b7817739111556c
parent58652578063094e101e47e20bbd9f1b381e7483d (diff)
downloadmongo-edu-9964d3803e7fa3bc6823a755de8101cb02333def.zip
download original subtitles fail to auto
-rw-r--r--.resume/resume.js3
-rw-r--r--lib/videos.js16
-rw-r--r--package.json2
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 <przemyslawplutadev@gmail.com> (http://przemyslawpluta.com)",
"description": "Select and download videos and handouts from university.mongodb.com courses",
"main": "./mongo-edu",