From 3cf49c5d1ca23383c8434a04459dcd6b38bd7006 Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Mon, 18 May 2020 20:15:22 +0300 Subject: [PATCH] Fix passing arguments to Utils.ts (#137) --- src/Utils.ts | 5 ++--- src/destreamer.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Utils.ts b/src/Utils.ts index aed9a45..807704f 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -4,7 +4,6 @@ import { execSync } from 'child_process'; import colors from 'colors'; import fs from 'fs'; import path from 'path'; -import { argv } from './CommandLineParser'; function sanitizeUrls(urls: string[]) { const rex = new RegExp(/(?:https:\/\/)?.*\/video\/[a-z0-9]{8}-(?:[a-z0-9]{4}\-){3}[a-z0-9]{12}$/, 'i'); @@ -123,11 +122,11 @@ export function checkRequirements() { } -export function makeUniqueTitle(title: string, outDir: string) { +export function makeUniqueTitle(title: string, outDir: string, skip?: boolean, format?: string) { let ntitle = title; let k = 0; - while (!argv.skip && fs.existsSync(outDir + path.sep + ntitle + '.' + argv.format)) + while (!skip && fs.existsSync(outDir + path.sep + ntitle + '.' + format)) ntitle = title + ' - ' + (++k).toString(); return ntitle; diff --git a/src/destreamer.ts b/src/destreamer.ts index bcca716..9153a40 100644 --- a/src/destreamer.ts +++ b/src/destreamer.ts @@ -173,7 +173,7 @@ async function downloadVideo(videoUrls: string[], outputDirectories: string[], s console.log(colors.yellow(`\nDownloading Video: ${video.title}\n`)); - video.title = makeUniqueTitle(sanitize(video.title) + ' - ' + video.date, outputDirectories[j]); + video.title = makeUniqueTitle(sanitize(video.title) + ' - ' + video.date, outputDirectories[j], argv.skip, argv.format); // Very experimental inline thumbnail rendering if (!argv.noExperiments)