From 066fd0df640ef9cbe4a727017ff608615484e2e3 Mon Sep 17 00:00:00 2001 From: Jake Date: Tue, 4 May 2021 18:52:27 -0400 Subject: [PATCH 1/3] fixed empty token file handling --- funi.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/funi.js b/funi.js index e6b7c7c..5868ff5 100644 --- a/funi.js +++ b/funi.js @@ -42,11 +42,19 @@ let cfg = { // token let token = getYamlCfg(tokenFile); -token = token.token ? token.token : false; +let emptyToken = false; +try{ + token = token.token ? token.token : false; +} +catch(error){ + token = false; + emptyToken = true; +} // info if token not set if(!token){ - console.log('[INFO] Token not set!\n'); + if(emptyToken) console.log('[WARN] token.yml is empty!\n'); + else console.log('[INFO] Token not set!\n'); } // cli From e0bafdd9b4837d4a0858578ce8918bf4366d4e9a Mon Sep 17 00:00:00 2001 From: Jake Date: Tue, 4 May 2021 22:52:30 -0400 Subject: [PATCH 2/3] added handling for empty and non-existant config files --- funi.js | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/funi.js b/funi.js index 5868ff5..d3b8a8a 100644 --- a/funi.js +++ b/funi.js @@ -40,21 +40,42 @@ let cfg = { cli: getYamlCfg(cliCfgFile), }; +// make sure cfg params aren't empty +if (cfg.bin === null){ + cfg.bin = {}; + console.log('[WARN] bin-path.yml is empty or does not exist!\n'); +} +if (!cfg.bin.hasOwnProperty('ffmpeg')) cfg.bin.ffmpeg = './bin/ffmpeg'; +if (!cfg.bin.hasOwnProperty('mkvmerge')) cfg.bin.mkvmerge = './bin/mkvmerge'; + +if (cfg.dir === null){ + cfg.dir = {}; + console.log('[WARN] dir-path.yml is empty or does not exist!\n'); +} +if (!cfg.dir.hasOwnProperty('content')) cfg.dir.content = './videos/'; +if (!cfg.dir.hasOwnProperty('trash')) cfg.dir.trash = "./videos/_trash/"; + +if (cfg.cli === null){ + cfg.cli = {}; + console.log('[WARN] cli-defaults.yml is empty or does not exist!\n'); +} +if (!cfg.cli.hasOwnProperty('releaseGroup')) cfg.cli.releaseGroup = "Funimation"; +if (!cfg.cli.hasOwnProperty('videoLayer')) cfg.cli.videoLayer = 7; +if (!cfg.cli.hasOwnProperty('fileSuffix')) cfg.cli.fileSuffix = "SIZEp"; +if (!cfg.cli.hasOwnProperty('nServer')) cfg.cli.nServer = 1; +if (!cfg.cli.hasOwnProperty('mp4mux')) cfg.cli.mp4mux = false; +if (!cfg.cli.hasOwnProperty('muxSubs')) cfg.cli.muxSubs = false; +if (!cfg.cli.hasOwnProperty('noCleanUp')) cfg.cli.noCleanUp = false; + // token let token = getYamlCfg(tokenFile); -let emptyToken = false; -try{ - token = token.token ? token.token : false; -} -catch(error){ - token = false; - emptyToken = true; -} +if (token === null) token = false; +else if (token.token === null) token = false; +else token = token.token; // info if token not set if(!token){ - if(emptyToken) console.log('[WARN] token.yml is empty!\n'); - else console.log('[INFO] Token not set!\n'); + console.log('[INFO] Token not set!\n'); } // cli From a69f83fea108d6f74339a1d920ba0178f345a1e6 Mon Sep 17 00:00:00 2001 From: Jake K Date: Tue, 6 Jul 2021 11:24:02 -0400 Subject: [PATCH 3/3] fixed eslint errors, removed cli and bin defaults --- funi.js | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/funi.js b/funi.js index 22d0b4e..8ac0d38 100644 --- a/funi.js +++ b/funi.js @@ -37,31 +37,23 @@ let cfg = { cli: getYamlCfg(cliCfgFile), }; -// make sure cfg params aren't empty -// If they are, update them with some defaults +// make sure cfg params aren't null if (cfg.bin === null){ - cfg.bin = {}; - console.log('[WARN] bin-path.yml is empty or does not exist!\n'); + cfg.bin = {}; + console.log('[WARN] bin-path.yml is empty or does not exist!\n'); } -if (!cfg.bin.hasOwnProperty('ffmpeg')) cfg.bin.ffmpeg = './bin/ffmpeg'; -if (!cfg.bin.hasOwnProperty('mkvmerge')) cfg.bin.mkvmerge = './bin/mkvmerge'; if (cfg.dir === null){ - cfg.dir = {}; - console.log('[WARN] dir-path.yml is empty or does not exist!\n'); + cfg.dir = {}; + console.log('[WARN] dir-path.yml is empty or does not exist!\n'); } -if (!cfg.dir.hasOwnProperty('content')) cfg.dir.content = './videos/'; + +if (!Object.prototype.hasOwnProperty.call(cfg.dir, 'content')) cfg.dir.content = './videos/'; if (cfg.cli === null){ - cfg.cli = {}; - console.log('[WARN] cli-defaults.yml is empty or does not exist!\n'); + cfg.cli = {}; + console.log('[WARN] cli-defaults.yml is empty or does not exist!\n'); } -if (!cfg.cli.hasOwnProperty('releaseGroup')) cfg.cli.releaseGroup = "Funimation"; -if (!cfg.cli.hasOwnProperty('videoLayer')) cfg.cli.videoLayer = 7; -if (!cfg.cli.hasOwnProperty('nServer')) cfg.cli.nServer = 1; -if (!cfg.cli.hasOwnProperty('mp4mux')) cfg.cli.mp4mux = false; -if (!cfg.cli.hasOwnProperty('muxSubs')) cfg.cli.muxSubs = false; -if (!cfg.cli.hasOwnProperty('noCleanUp')) cfg.cli.noCleanUp = false; /* Normalise paths for use outside the current directory */ for (let key of Object.keys(cfg.dir)) { @@ -950,4 +942,4 @@ function parseFileName(input, title, episode, showTitle, season, width, height) } } return shlp.cleanupFilename(input); -} \ No newline at end of file +}