From a87d467ad76505312fe63c597ee03a66126d0492 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 12 Feb 2018 12:48:58 +0100 Subject: Fix upload from CLI script --- server/tools/upload-directory.ts | 82 ---------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 server/tools/upload-directory.ts (limited to 'server/tools/upload-directory.ts') diff --git a/server/tools/upload-directory.ts b/server/tools/upload-directory.ts deleted file mode 100644 index c0094f852..000000000 --- a/server/tools/upload-directory.ts +++ /dev/null @@ -1,82 +0,0 @@ -import * as program from 'commander' -import * as Promise from 'bluebird' -import { isAbsolute, join } from 'path' - -import { readdirPromise } from '../helpers/core-utils' -import { execCLI } from '../tests/utils/index' - -program - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .option('-i, --input ', 'Videos directory absolute path') - .option('-d, --description ', 'Video descriptions') - .option('-c, --category ', 'Video categories') - .option('-l, --licence ', 'Video licences') - .option('-t, --tags ', 'Video tags', list) - .parse(process.argv) - -if ( - !program['url'] || - !program['username'] || - !program['password'] || - !program['input'] || - !program['description'] || - !program['category'] || - !program['licence'] || - !program['tags'] -) { - throw new Error('All arguments are required.') -} - -if (isAbsolute(program['input']) === false) { - throw new Error('Input path should be absolute.') -} - -let command = `npm run ts-node -- ${__dirname}/get-access-token.ts` -command += ` -u "${program['url']}"` -command += ` -n "${program['username']}"` -command += ` -p "${program['password']}"` - -execCLI(command) - .then(stdout => { - const accessToken = stdout.replace('\n', '') - - console.log(accessToken) - - return readdirPromise(program['input']).then(files => ({ accessToken, files })) - }) - .then(({ accessToken, files }) => { - return Promise.each(files, file => { - const video = { - tags: program['tags'], - name: file, - description: program['description'], - category: program['category'], - licence: program['licence'] - } - - let command = `npm run ts-node -- ${__dirname}/upload.ts` - command += ` -u "${program['url']}"` - command += ` -a "${accessToken}"` - command += ` -n "${video.name}"` - command += ` -d "${video.description}"` - command += ` -c "${video.category}"` - command += ` -l "${video.licence}"` - command += ` -t "${video.tags.join(',')}"` - command += ` -f "${join(program['input'], file)}"` - - return execCLI(command).then(stdout => console.log(stdout)) - }) - }) - .then(() => process.exit(0)) - .catch(err => { - console.error(err) - process.exit(-1) - }) - -// ---------------------------------------------------------------------------- - -function list (val) { - return val.split(',') -} -- cgit v1.2.3