summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorprzemyslawpluta <przemekpluta@hotmail.com>2014-12-12 09:54:03 +0000
committerprzemyslawpluta <przemekpluta@hotmail.com>2014-12-12 09:54:03 +0000
commitc15c4a850abd3f2310ceb8261255d7f87b73474b (patch)
tree82bd35bed80c201d0bcb47428bd73ad2f8513072 /lib
parenta0d787bafab2490f9a9c84247ef1edc3d4e47f13 (diff)
downloadmongo-edu-c15c4a850abd3f2310ceb8261255d7f87b73474b.zip
update
subtitles download fix cleanup version bump
Diffstat (limited to 'lib')
-rw-r--r--lib/videos.js26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/videos.js b/lib/videos.js
index c5d4806..70d3939 100644
--- a/lib/videos.js
+++ b/lib/videos.js
@@ -63,8 +63,6 @@ var handleList = function handleList(list, tags) {
quality = (!hq) ? '18' : '22',
opt = (!ncc) ? ['--max-quality=' + quality] : ['--max-quality=' + quality, '--no-check-certificate'], i, count;
- if (cc) { opt = opt.concat(['--write-sub', '--srt-lang=en']); }
-
if (verbose) { opt = opt.concat(['--verbose']); }
if (proxy) { opt = opt.concat(['--proxy', proxy]); }
@@ -148,6 +146,23 @@ var handleList = function handleList(list, tags) {
},
+ getSubtitles = function getSubtitles(item, left, currentList, tags) {
+ 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.');
+ } else {
+ console.log('i'.magenta + ' Subtitles downloaded.');
+ }
+ if (left) { console.log('i'.magenta + ' ' + left); }
+ handleList(currentList, tags);
+ });
+ },
+
getVideos = function getVideos(item, nocc) {
if (handout) { return getHandouts(item); }
@@ -169,18 +184,13 @@ var handleList = function handleList(list, tags) {
});
dl.on('error', function error(err) {
- if (err.message.indexOf('video doesn\'t have subtitles') !== -1) {
- console.log('i'.magenta + ' No Closed Captions Available For: ' + stash.filename.cyan + ' > ' + item);
- return getVideos(item, _.without(opt, '--write-sub', '--srt-lang=en'));
- }
console.log(err.stack);
});
dl.on('end', function end() {
var left = (currentList.length)? currentList.length + ' left ...' : '';
console.timeEnd('i'.magenta + ' ' + stash.filename + '. Done in');
- if (left) { console.log('i'.magenta + ' ' + left); }
- handleList(currentList, tags);
+ getSubtitles(item, left, currentList, tags);
});
};