summaryrefslogtreecommitdiff
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
parenta0d787bafab2490f9a9c84247ef1edc3d4e47f13 (diff)
downloadmongo-edu-c15c4a850abd3f2310ceb8261255d7f87b73474b.zip
update
subtitles download fix cleanup version bump
-rw-r--r--.gitignore2
-rw-r--r--lib/videos.js26
-rw-r--r--package.json10
3 files changed, 23 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore
index 4c9cff8..96efa29 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,5 +20,3 @@ mongo-edu.wiki
node_modules
bin/*.json
-
-lib/question.js
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);
});
};
diff --git a/package.json b/package.json
index 1fef6ac..d88fa8c 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "mongo-edu",
"preferGlobal": true,
- "version": "0.2.2",
+ "version": "0.2.3",
"author": "Przemyslaw Pluta <przemyslawplutadev@gmail.com> (http://przemyslawpluta.com)",
"description": "Select and download videos and handouts from university.mongodb.com courses",
"main": "./mongo-edu",
@@ -34,20 +34,20 @@
"colors": "~1.0.3",
"easy-table": "~0.3.0",
"filesize": "~2.0.3",
- "glob": "~4.0.6",
+ "glob": "~4.3.1",
"inquirer": "~0.8.0",
"lodash": "~2.4.1",
"mkdirp": "~0.5.0",
"mv": "~2.0.3",
"path-extra": "~0.3.0",
"progress": "~1.1.8",
- "request": "~2.47.0",
+ "request": "~2.51.0",
"request-progress": "~0.3.1",
"rimraf": "~2.2.8",
"unzip": "~0.1.11",
- "which": "~1.0.5",
+ "which": "~1.0.8",
"yargs": "~1.3.1",
- "youtube-dl": "~1.5.16"
+ "youtube-dl": "~1.6.0"
},
"engines": {
"node": ">= 0.8.x"