Bläddra i källkod

add '--create-dir' command

If set, the download will fail if the output dir already exists.
Alternatively, any existing dir will be reused or created as needed.
Gil Pedersen 13 år sedan
förälder
incheckning
5669cfb84c
1 ändrade filer med 5 tillägg och 7 borttagningar
  1. 5 7
      bin/hlsrecord

+ 5 - 7
bin/hlsrecord

@@ -7,10 +7,11 @@
 var hlsrecord = require('commander');
 var hlsrecord = require('commander');
 hlsrecord.version(require('../package').version)
 hlsrecord.version(require('../package').version)
    .usage('[options] <url>')
    .usage('[options] <url>')
-   .option('-o, --output <dir>', 'output directory')
+   .option('-o, --output <dir>', 'Output directory')
+   .option('-c, --create-dir', 'Explicitly create output dir')
    .option('-b, --begin-date <date>', 'Start recording at', dateValue)
    .option('-b, --begin-date <date>', 'Start recording at', dateValue)
    .option('-e, --end-date <date>', 'Stop recording at', dateValue)
    .option('-e, --end-date <date>', 'Stop recording at', dateValue)
-   .option('-a, --user-agent <string>', 'HTTP User-Agent')
+//   .option('-a, --user-agent <string>', 'HTTP User-Agent')
 //   .option('-f, --full', 'record all variants')
 //   .option('-f, --full', 'record all variants')
    .parse(process.argv);
    .parse(process.argv);
 
 
@@ -44,6 +45,8 @@ var src = hlsrecord.args[0];
 if (!src) return hlsrecord.help();
 if (!src) return hlsrecord.help();
 
 
 var outDir = hlsrecord.output || 'stream';
 var outDir = hlsrecord.output || 'stream';
+if (hlsrecord.createDir)
+  fs.mkdirSync(outDir);
 
 
 if (hlsrecord.beginDate)
 if (hlsrecord.beginDate)
   console.log('fetching from:', hlsrecord.beginDate);
   console.log('fetching from:', hlsrecord.beginDate);
@@ -57,11 +60,6 @@ var options = {
   highWaterMark:0,
   highWaterMark:0,
 };
 };
 
 
-if (!options.startDate) {
-  options.startDate = new Date();
-  options.fullStream = false;
-}
-
 function createReader(src) {
 function createReader(src) {
   return reader(src, options);
   return reader(src, options);
 }
 }