diff options
author | przemyslawpluta <przemekpluta@hotmail.com> | 2016-01-13 21:23:28 +0000 |
---|---|---|
committer | przemyslawpluta <przemekpluta@hotmail.com> | 2016-01-13 21:23:28 +0000 |
commit | 58652578063094e101e47e20bbd9f1b381e7483d (patch) | |
tree | 22a02e14c25a96f58ee0f663c961563390ef2ae7 /lib | |
parent | 725424153522edcca253203127defab8cb6174d8 (diff) | |
download | mongo-edu-58652578063094e101e47e20bbd9f1b381e7483d.zip |
download subtitles only
Diffstat (limited to 'lib')
-rw-r--r-- | lib/videos.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/videos.js b/lib/videos.js index 9c90f92..0fe77b4 100644 --- a/lib/videos.js +++ b/lib/videos.js @@ -22,7 +22,7 @@ var path = require('path'), getYouTubeID = require('get-youtube-id'); var isDebug = /[debug]/, downloadPath = '', proxy = '', downloadList = [], hash = {}, - co = false, ncc = false, handout = false, cc = false, uz = false, hq = false, verbose = false, retry = 10, maxRetry; + co = false, ncc = false, handout = false, cc = false, uz = false, hq = false, verbose = false, retry = 10, cco = false, maxRetry; function setOptions(argv) { @@ -38,6 +38,10 @@ function setOptions(argv) { if (argv.co) { co = true; } if (argv.retry) { retry = argv.retry; } if (argv.verbose) { verbose = true; } + if (argv.cco) { + cc = true; + cco = true; + } } function rename(downloadPath, item, id, count, pass) { @@ -70,6 +74,8 @@ var handleList = function handleList(list, tags) { if (proxy) { opt = opt.concat(['--proxy', proxy]); } + if (cco) { opt = opt.concat(['--skip-download']); } + var getHandouts = function getHandouts(item) { var name = path.basename(item), bar, dounloadFile, dlh, left, extname, unzipFile, progressSoFar = -1, hold = 0, @@ -167,6 +173,8 @@ var handleList = function handleList(list, tags) { if (handout) { return getHandouts(item); } + if (cco) { return getSubtitlesOnly(item); } + var downloaded = 0, size = 0, stash = {}, bar; if (fs.existsSync(downloadPath + hash[item])) { @@ -226,6 +234,17 @@ var handleList = function handleList(list, tags) { }); }, + getSubtitlesOnly = function getSubtitlesOnly(item) { + + youtubedl.getInfo(item, [], function getInfo(err, info) { + if (err) { console.log('i'.red + ' Get Info Failed: '.red + err.stack); } + if (info) { console.log('i'.magenta + ' Downloading Subtitles: ' + info._filename.cyan + ' > ' + item); } + var left = (currentList.length) ? currentList.length + ' left ...' : ''; + getSubtitles(item, left, currentList, tags); + }); + + }, + delay = function delay(target) { setTimeout(function timeout() { getVideos(target); }, 5000); }; |