Explorar o código

Now that we have cookies, persistant config file, we can log
and stay logged between run (or I hope so) so add a delog command,
and make the cookie monster happy.

Godzil %!s(int64=5) %!d(string=hai) anos
pai
achega
9fb85d4376
Modificáronse 2 ficheiros con 14 adicións e 0 borrados
  1. 13 0
      src/batch.ts
  2. 1 0
      src/interface/IConfig.d.ts

+ 13 - 0
src/batch.ts

@@ -3,6 +3,7 @@ import commander = require('commander');
 import fs = require('fs');
 import path = require('path');
 import log = require('./log');
+import my_request = require('./my_request');
 import cfg = require('./config');
 import series from './series';
 
@@ -27,6 +28,17 @@ export default function(args: string[], done: (err?: Error) => void)
   // Update the config file with new parameters
   cfg.save(config);
 
+  if (config.unlog)
+  {
+    config.crDeviceId = undefined;
+    config.user = undefined;
+    config.pass = undefined;
+    my_request.eatCookies(config);
+    cfg.save(config);
+    log.info("Unlogged!");
+    process.exit(0);
+  }
+
   // set resolution
   if (config.resolution)
   {
@@ -307,6 +319,7 @@ function parse(args: string[]): IConfigLine
     // Authentication
     .option('-p, --pass <s>', 'The password.')
     .option('-u, --user <s>', 'The e-mail address or username.')
+    .option('-d, --unlog', 'Unlog')
     // Disables
     .option('-c, --cache', 'Disables the cache.')
     .option('-m, --merge', 'Disables merging subtitles and videos.')

+ 1 - 0
src/interface/IConfig.d.ts

@@ -19,6 +19,7 @@ interface IConfig {
   batch?: string;
   verbose?: boolean;
   debug?: boolean;
+  unlog?: boolean;
   retry?: number;
   // Login options
   logUsingApi?: boolean;