diff options
author | przemyslawpluta <przemekpluta@hotmail.com> | 2016-01-14 18:45:04 +0000 |
---|---|---|
committer | przemyslawpluta <przemekpluta@hotmail.com> | 2016-01-14 18:45:04 +0000 |
commit | 9964d3803e7fa3bc6823a755de8101cb02333def (patch) | |
tree | 9b31c165ab848c62fb94a43c6b7817739111556c /lib/videos.js | |
parent | 58652578063094e101e47e20bbd9f1b381e7483d (diff) | |
download | mongo-edu-9964d3803e7fa3bc6823a755de8101cb02333def.zip |
download original subtitles fail to auto
Diffstat (limited to 'lib/videos.js')
-rw-r--r-- | lib/videos.js | 16 |
1 files changed, 11 insertions, 5 deletions
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); |