diff --git a/Community/Tdarr_Plugin_a9he_New_file_size_check.js b/Community/Tdarr_Plugin_a9he_New_file_size_check.js index 32e99d6..c352eba 100644 --- a/Community/Tdarr_Plugin_a9he_New_file_size_check.js +++ b/Community/Tdarr_Plugin_a9he_New_file_size_check.js @@ -52,6 +52,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { const ratio = parseInt((newSize / oldSize) * 100, 10); + console.log(newSize, oldSize); const sizeText = `New file has size ${newSize.toFixed(3)} MB which is ${ratio}% ` + `of original file size: ${oldSize.toFixed(3)} MB`; diff --git a/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js b/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js index 6f1fcc5..4cda5ca 100644 --- a/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js +++ b/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js @@ -1,6 +1,5 @@ // eslint-disable-next-line import/no-unresolved -// tdarrSkipTest const details = () => ({ id: 'Tdarr_Plugin_a9hf_New_file_duration_check', Stage: 'Pre-processing', diff --git a/tests/Community/Tdarr_Plugin_a9he_New_file_size_check.js b/tests/Community/Tdarr_Plugin_a9he_New_file_size_check.js index 7e1de0d..e990b36 100644 --- a/tests/Community/Tdarr_Plugin_a9he_New_file_size_check.js +++ b/tests/Community/Tdarr_Plugin_a9he_New_file_size_check.js @@ -5,11 +5,11 @@ const run = require('../helpers/run'); const tests = [ { input: { - file: require('../sampleData/media/sampleH264_1.json'), + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), librarySettings: {}, inputs: {}, otherArguments: { - originalLibraryFile: require('../sampleData/media/sampleH264_1.json'), + originalLibraryFile: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), }, }, output: { @@ -23,7 +23,7 @@ const tests = [ }, { input: { - file: require('../sampleData/media/sampleH264_1.json'), + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), librarySettings: {}, inputs: { upperBound: '110', @@ -44,7 +44,7 @@ const tests = [ }, { input: { - file: require('../sampleData/media/sampleH264_1.json'), + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), librarySettings: {}, inputs: { upperBound: '120', diff --git a/tests/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js b/tests/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js new file mode 100644 index 0000000..9497714 --- /dev/null +++ b/tests/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js @@ -0,0 +1,68 @@ +/* eslint max-len: 0 */ +const _ = require('lodash'); +const run = require('../helpers/run'); + +const tests = [ + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), + librarySettings: {}, + inputs: {}, + otherArguments: { + originalLibraryFile: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), + }, + }, + output: { + processFile: false, + preset: '', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: 'New file has duration 5.312 s which is 100.000% of original file duration: 5.312 s', + }, + }, + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), + librarySettings: {}, + inputs: { + upperBound: '110', + lowerBound: '35', + }, + otherArguments: { + originalLibraryFile: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.mediaInfo.track.filter((row) => row['@type'] === 'General')[0].Duration = 20; + return file; + })(), + }, + }, + output: 'New file duration not within limits. New file has duration 5.312 s which is 26.560% of original file duration: 20 s. lowerBound is 35%', + error: { + shouldThrow: true, + }, + }, + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), + librarySettings: {}, + inputs: { + upperBound: '110', + lowerBound: '35', + }, + otherArguments: { + originalLibraryFile: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.mediaInfo.track.filter((row) => row['@type'] === 'General')[0].Duration = 1; + return file; + })(), + }, + }, + output: 'New file duration not within limits. New file has duration 5.312 s which is 531.200% of original file duration: 1 s. upperBound is 110%', + error: { + shouldThrow: true, + }, + }, +]; + +run(tests);