fixed the import syntax

now the simulation flag properly translate in youtube-del flag too
This commit is contained in:
Luca 2020-03-29 21:41:53 +02:00
parent 016d96377a
commit 089fec6001

View file

@ -4,14 +4,14 @@ import { terminal as term } from 'terminal-kit';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { BrowserTests } from './BrowserTests'; import { BrowserTests } from './BrowserTests';
import yargs = require('yargs'); import yargs from 'yargs'
import sanitize = require('sanitize-filename'); import sanitize from 'sanitize-filename'
import axios from 'axios'; import axios from 'axios';
/** /**
* exitCode 25 = cannot split videoID from videUrl * exitCode 25 = cannot split videoID from videUrl
* exitCode 27 = no hlsUrl in the api * exitCode 27 = no hlsUrl in the API response
* exitCode 88 = error extracting cookies * exitCode 88 = error extracting cookies
*/ */
@ -41,11 +41,13 @@ if (argv.simulate){
console.info('Video URLs: %s', argv.videoUrls); console.info('Video URLs: %s', argv.videoUrls);
console.info('Username: %s', argv.username); console.info('Username: %s', argv.username);
term.blue("There will be no video downloaded, it's only a simulation \n") term.blue("There will be no video downloaded, it's only a simulation \n")
console.log("\n")
} else { } else {
console.info('Video URLs: %s', argv.videoUrls); console.info('Video URLs: %s', argv.videoUrls);
console.info('Username: %s', argv.username); console.info('Username: %s', argv.username);
console.info('Output Directory: %s', argv.outputDirectory); console.info('Output Directory: %s', argv.outputDirectory);
console.info('Video/Audio Quality: %s', argv.format); console.info('Video/Audio Quality: %s', argv.format);
console.log("\n")
} }
@ -128,25 +130,22 @@ async function rentVideoForLater(videoUrls: string[], username: string, outputDi
title = (sanitize(title) == "") ? `Video${videoUrls.indexOf(videoUrl)}` : sanitize(title) title = (sanitize(title) == "") ? `Video${videoUrls.indexOf(videoUrl)}` : sanitize(title)
if (!argv.simulate) { term.blue("Video title is: ")
console.log('Spawning youtube-dl with cookie and HLS URL...'); console.log(`${title} \n`)
let format = ''
if (argv.format) {
format = `-f "${argv.format}"`
}
const youtubedlCmd = 'youtube-dl --no-call-home --no-warnings ' + format + console.log('Spawning youtube-dl with cookie and HLS URL...');
` --output "${outputDirectory}/${title}.mp4" --add-header Cookie:"${cookie}" "${hlsUrl}"`
// console.log(`\n\n[DEBUG] Invoking youtube-dl: ${youtubedlCmd}\n\n`); const format = argv.format ? `-f "${argv.format}"` : ""
var result = execSync(youtubedlCmd, { stdio: 'inherit' });
} else { var youtubedlCmd = 'youtube-dl --no-call-home --no-warnings ' + format +
// Logging the video info ` --output "${outputDirectory}/${title}.mp4" --add-header ` +
term.blue("Video title is: ") `Cookie:"${cookie}" "${hlsUrl}"`
console.log(`${title}`)
term.blue("Video url is: ") if (argv.simulate)
console.log(`${hlsUrl}`) youtubedlCmd = youtubedlCmd + " -s"
}
// console.log(`\n\n[DEBUG] Invoking youtube-dl: ${youtubedlCmd}\n\n`);
var result = execSync(youtubedlCmd, { stdio: 'inherit' });
} }
console.log("At this point Chrome's job is done, shutting it down..."); console.log("At this point Chrome's job is done, shutting it down...");