summaryrefslogtreecommitdiff
path: root/lib/videos.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/videos.js')
-rw-r--r--lib/videos.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/videos.js b/lib/videos.js
index 48327ac..f64d330 100644
--- a/lib/videos.js
+++ b/lib/videos.js
@@ -18,7 +18,7 @@ var path = require('path'),
execFile = require('child_process').execFile,
_ = require('lodash');
-var downloadPath = '', ncc = false, handout = false, cc = false, uz = false, hq = false;
+var downloadPath = '', downloadList = [], ncc = false, handout = false, cc = false, uz = false, hq = false, isWin = /^win/.test(process.platform);
var setOptions = function setOptions(argv) {
@@ -124,6 +124,7 @@ var handleList = function handleList(list) {
var dl = youtubedl.download(item, downloadPath, opt), bar;
dl.on('download', function download(data) {
+ downloadList.push(path.basename(data.filename));
console.log('[' + 'i'.magenta + '] Downloading: ' + data.filename.cyan + ' > ' + item);
bar = new ProgressBar('[' + '>'.green + '] ' + data.size + ' [:bar] :percent :etas', { complete: '=', incomplete: ' ', width: 20, total: 100.0 });
});
@@ -143,7 +144,6 @@ var handleList = function handleList(list) {
console.log('[' + '>'.magenta + '] ' + data.filename + '.' + left);
} else {
console.log('[' + 'i'.green + '] Done in ' + data.timeTakenms + 'ms.' + left);
-
}
} else {
console.log('[' + 'i'.red + '] Download Issues');
@@ -153,7 +153,11 @@ var handleList = function handleList(list) {
};
if (currentList.length) { return getVideos(currentList.shift()); }
- console.log('[ Finished ]'.green);
+
+ fs.writeFile(downloadPath + 'Course_Order.txt', downloadList.join((!isWin) ? '\n' : '\r\n'), function write(err) {
+ if (err !== null) { console.log(err.stack); }
+ console.log('[ Finished ]'.green);
+ });
};
@@ -260,11 +264,11 @@ module.exports = {
if (stderr) { return callback(new Error(stderr.slice(7))); }
var data = stdout.trim().split(/\r?\n/);
- var out = [], total = data.length, count = 0;
+ var out = [], total = data.length, count = 0, i;
if (data.length) {
- for (var i = 0; i < total / 2; i++) {
+ for (i = 0; i < total / 2; i++) {
count = count + 1;
out.push({ name: data.shift(), value: 'https://www.youtube.com/watch?v=' + data.shift(), id: count});
}