From 84189d5cfec3aa6bb142a3fb458728bd27360e7a Mon Sep 17 00:00:00 2001 From: aunefyren Date: Wed, 23 Mar 2022 22:19:02 +0100 Subject: [PATCH 1/7] Music library plugin, ALAC to FLAC Made a plugin that converts from Apples ALAC codec to FLAC, losslessly. I use this myself and figured someone else might use it because there are no music library plugins. --- .../Tdarr_Plugin_fu72_aune_alac_to_flac.js | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js diff --git a/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js b/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js new file mode 100644 index 0000000..ff457ff --- /dev/null +++ b/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js @@ -0,0 +1,81 @@ +function details() { + return { + id: "Tdarr_Plugin_fu72_aune_alac_to_flac", + Stage: "Pre-processing", + Name: "Aune - ALAC to Flac", + Type: "Audio", + Operation: "Transcode", + Description: `[Contains built-in filter] This plugin transcodes all ALAC-tracks to FLAC. It ignores files that contains video streams and is made for music libraries.\n\n`, + Version: "1.00", + Link: "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js", + Tags: "pre-processing,ffmpeg,audio only", + }; +} + +function plugin(file) { + //Must return this object + + var response = { + processFile: false, + preset: "", + container: "." + file.container, + handBrakeMode: false, + FFmpegMode: false, + reQueueAfter: false, + infoLog: "", + }; + + // Mark video as false + var video = false; + // Check every information stream in the file + for(var i = 0; i < file.ffProbeData.streams.length; i++) { + // If one stream is video and the framerate is not '0/0', mark file as video + if(file.ffProbeData.streams[i].codec_type.toLowerCase() == 'video' && file.ffProbeData.streams[i].avg_frame_rate.toLowerCase() !== "0/0") { + video = true; + break; + } + } + + // If file is video, do not process + if (video) { + console.log("File is a video."); + response.infoLog += "☒File is a video!\n"; + response.processFile = false; + + return response; + + // If file is not video, check codec + } else { + // Initiate transcode boolean as false + var transcode = false; + + // Check every stream for 'audio' type and 'alac' codec, and mark transcode as true + for (var i = 0; i < file.ffProbeData.streams.length; i++) { + if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") { + if(file.ffProbeData.streams[i].codec_name.toLowerCase() == "alac") { + transcode = true; + break; + } + } + } + + // Either transcode to FLAC (lossess) or ignore file + if(transcode) { + response.processFile = true; + response.preset = ", -f flac"; + response.container = ".flac"; + response.handBrakeMode = false; + response.FFmpegMode = true; + response.reQueueAfter = true; + response.infoLog += "☒Found ALAC codec!\n"; + return response; + } else { + response.processFile = false; + response.infoLog += "☑No ALAC codec found!\n"; + return response; + } + } +} + +module.exports.details = details; +module.exports.plugin = plugin; \ No newline at end of file From 36e21d1b6aafd15bab4b96a158f1e03bd9e5b13d Mon Sep 17 00:00:00 2001 From: aunefyren Date: Wed, 23 Mar 2022 23:16:21 +0100 Subject: [PATCH 2/7] Reformat --- .../Tdarr_Plugin_fu72_aune_alac_to_flac.js | 118 +++++++----------- 1 file changed, 43 insertions(+), 75 deletions(-) diff --git a/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js b/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js index ff457ff..cad9f59 100644 --- a/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js +++ b/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js @@ -1,81 +1,49 @@ function details() { return { - id: "Tdarr_Plugin_fu72_aune_alac_to_flac", - Stage: "Pre-processing", - Name: "Aune - ALAC to Flac", - Type: "Audio", - Operation: "Transcode", - Description: `[Contains built-in filter] This plugin transcodes all ALAC-tracks to FLAC. It ignores files that contains video streams and is made for music libraries.\n\n`, - Version: "1.00", - Link: "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js", - Tags: "pre-processing,ffmpeg,audio only", + id: 'Tdarr_Plugin_fu72_aune_alac_to_flac', + Stage: 'Pre-processing', + Name: 'Aune - ALAC to Flac', + Type: 'Audio', + Operation: 'Transcode', + Description: '[Contains built-in filter] This plugin transcodes all ALAC-tracks to FLAC. ' + + 'It ignores files that contains video streams and is made for music libraries.\n\n', + Version: '1.00', + Link: 'https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js', + Tags: 'pre-processing,ffmpeg,audio only', }; -} - -function plugin(file) { - //Must return this object - - var response = { - processFile: false, - preset: "", - container: "." + file.container, - handBrakeMode: false, - FFmpegMode: false, - reQueueAfter: false, - infoLog: "", + } + + // eslint-disable-next-line no-unused-vars + function plugin(file, librarySettings, inputs, otherArguments) { + const lib = require('../methods/lib')(); + // eslint-disable-next-line no-unused-vars,no-param-reassign + inputs = lib.loadDefaultValues(inputs, details); + const response = { + processFile: false, + preset: ' -f flac', + container: '.flac', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '', }; - - // Mark video as false - var video = false; - // Check every information stream in the file - for(var i = 0; i < file.ffProbeData.streams.length; i++) { - // If one stream is video and the framerate is not '0/0', mark file as video - if(file.ffProbeData.streams[i].codec_type.toLowerCase() == 'video' && file.ffProbeData.streams[i].avg_frame_rate.toLowerCase() !== "0/0") { - video = true; - break; - } + + if (file.ffProbeData.streams.filter((x) => x.codec_type === 'video').length) { + response.infoLog += '☒File contains video!\n'; + return response; } - - // If file is video, do not process - if (video) { - console.log("File is a video."); - response.infoLog += "☒File is a video!\n"; - response.processFile = false; - - return response; - - // If file is not video, check codec - } else { - // Initiate transcode boolean as false - var transcode = false; - - // Check every stream for 'audio' type and 'alac' codec, and mark transcode as true - for (var i = 0; i < file.ffProbeData.streams.length; i++) { - if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") { - if(file.ffProbeData.streams[i].codec_name.toLowerCase() == "alac") { - transcode = true; - break; - } - } - } - - // Either transcode to FLAC (lossess) or ignore file - if(transcode) { - response.processFile = true; - response.preset = ", -f flac"; - response.container = ".flac"; - response.handBrakeMode = false; - response.FFmpegMode = true; - response.reQueueAfter = true; - response.infoLog += "☒Found ALAC codec!\n"; - return response; - } else { - response.processFile = false; - response.infoLog += "☑No ALAC codec found!\n"; - return response; - } + + // Either transcode to FLAC (lossless) or ignore file + if (file.ffProbeData.streams.filter( + (x) => x.codec_type.toLowerCase() === 'audio' && x.codec_name.toLowerCase() === 'alac', + ).length) { + response.processFile = true; + response.infoLog += '☒Found ALAC codec!\n'; + return response; } -} - -module.exports.details = details; -module.exports.plugin = plugin; \ No newline at end of file + response.infoLog += '☑No ALAC codec found!\n'; + return response; + } + + module.exports.details = details; + module.exports.plugin = plugin; \ No newline at end of file From 8d61fbda92482738a8dc3a60cd88858837fd63dd Mon Sep 17 00:00:00 2001 From: Aune <31650531+aunefyren@users.noreply.github.com> Date: Wed, 23 Mar 2022 23:54:35 +0100 Subject: [PATCH 3/7] Readded frame rate check --- Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js b/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js index cad9f59..5a08e6e 100644 --- a/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js +++ b/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js @@ -28,7 +28,7 @@ function details() { infoLog: '', }; - if (file.ffProbeData.streams.filter((x) => x.codec_type === 'video').length) { + if (file.ffProbeData.streams.filter((x) => x.codec_type === 'video' && x.avg_frame_rate !== '0/0').length) { response.infoLog += '☒File contains video!\n'; return response; } @@ -46,4 +46,4 @@ function details() { } module.exports.details = details; - module.exports.plugin = plugin; \ No newline at end of file + module.exports.plugin = plugin; From ab47ab7e9239a7ac74d6281b8eb7af457358d77c Mon Sep 17 00:00:00 2001 From: aunefyren Date: Thu, 24 Mar 2022 11:42:31 +0100 Subject: [PATCH 4/7] Big letters in FLAC --- Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js b/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js index 5a08e6e..1a5a5ba 100644 --- a/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js +++ b/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js @@ -2,7 +2,7 @@ function details() { return { id: 'Tdarr_Plugin_fu72_aune_alac_to_flac', Stage: 'Pre-processing', - Name: 'Aune - ALAC to Flac', + Name: 'Aune - ALAC to FLAC', Type: 'Audio', Operation: 'Transcode', Description: '[Contains built-in filter] This plugin transcodes all ALAC-tracks to FLAC. ' From 87d3051cfc2a01e8bb791871ebebec0e2acaa523 Mon Sep 17 00:00:00 2001 From: aunefyren Date: Tue, 29 Mar 2022 12:46:38 +0200 Subject: [PATCH 5/7] Remade plugin to convert user-selected codecs to FLAC --- .../Tdarr_Plugin_fu69_aune_audio_to_flac.js | 77 +++++++++++++++++++ .../Tdarr_Plugin_fu72_aune_alac_to_flac.js | 49 ------------ 2 files changed, 77 insertions(+), 49 deletions(-) create mode 100644 Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js delete mode 100644 Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js diff --git a/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js b/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js new file mode 100644 index 0000000..ce546cf --- /dev/null +++ b/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js @@ -0,0 +1,77 @@ +function details() { + return { + id: 'Tdarr_Plugin_fu69_aune_audio_to_flac', + Stage: 'Pre-processing', + Name: 'Aune - Audio to FLAC', + Type: 'Audio', + Operation: 'Transcode', + Description: 'This plugin transcodes different audio codecs to FLAC. ' + + 'Leaving the default inputs results in lossless conversion as ALAC and PCM codecs don\'t require transcoding for FLAC. It ignores files that contains video streams and is made for music libraries.\n\n', + Version: '1.00', + Link: 'https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js', + Tags: 'pre-processing,ffmpeg,audio only', + Inputs: [ + { + name: "codecs", + type: 'string', + defaultValue: 'alac,pcm_s16be,pcm_s16le,pcm_s24be,pcm_s24le,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le', + inputUI: { + type: 'text', + }, + tooltip: + `Select the codec(s) (comma seperated) you would like to transcode to FLAC. + \\nExample:\\n + alac + \\nExample:\\n + alac, pcm_s16be, mp3 + \\nExample:\\n + alac,pcm_s16be,pcm_s16le,pcm_s24be,pcm_s24le,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le`, + }, + ], + }; + } + + // eslint-disable-next-line no-unused-vars + function plugin(file, librarySettings, inputs, otherArguments) { + const lib = require('../methods/lib')(); + // eslint-disable-next-line no-unused-vars,no-param-reassign + inputs = lib.loadDefaultValues(inputs, details); + + if (inputs.codecs == "" || inputs.codecs == "undefined") { + response.infoLog += '☒No codecs selected!\n'; + return response; + } else { + inputs.codecs = inputs.codecs.split(","); + } + + const response = { + processFile: false, + preset: ' -c:a flac -f flac', + container: '.flac', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '', + }; + + if (file.ffProbeData.streams.filter((x) => x.codec_type === 'video' && x.avg_frame_rate !== '0/0').length) { + response.infoLog += '☒File contains video!\n'; + return response; + } + + // Either transcode to FLAC or ignore file + for(var i = 0; i < file.ffProbeData.streams.length; i++) { + for(var j = 0; j < inputs.codecs.length; j++) { + if(file.ffProbeData.streams[i].codec_type === 'audio' && file.ffProbeData.streams[i].codec_name.toLowerCase() === inputs.codecs[j].toLowerCase().trim()) { + response.processFile = true; + response.infoLog += '☒Found ' + inputs.codecs[j].toLowerCase().trim() + ' codec!\n'; + return response; + } + } + } + response.infoLog += '☑No matching codecs found!\n'; + return response; + } + + module.exports.details = details; + module.exports.plugin = plugin; diff --git a/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js b/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js deleted file mode 100644 index 1a5a5ba..0000000 --- a/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js +++ /dev/null @@ -1,49 +0,0 @@ -function details() { - return { - id: 'Tdarr_Plugin_fu72_aune_alac_to_flac', - Stage: 'Pre-processing', - Name: 'Aune - ALAC to FLAC', - Type: 'Audio', - Operation: 'Transcode', - Description: '[Contains built-in filter] This plugin transcodes all ALAC-tracks to FLAC. ' - + 'It ignores files that contains video streams and is made for music libraries.\n\n', - Version: '1.00', - Link: 'https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js', - Tags: 'pre-processing,ffmpeg,audio only', - }; - } - - // eslint-disable-next-line no-unused-vars - function plugin(file, librarySettings, inputs, otherArguments) { - const lib = require('../methods/lib')(); - // eslint-disable-next-line no-unused-vars,no-param-reassign - inputs = lib.loadDefaultValues(inputs, details); - const response = { - processFile: false, - preset: ' -f flac', - container: '.flac', - handBrakeMode: false, - FFmpegMode: true, - reQueueAfter: true, - infoLog: '', - }; - - if (file.ffProbeData.streams.filter((x) => x.codec_type === 'video' && x.avg_frame_rate !== '0/0').length) { - response.infoLog += '☒File contains video!\n'; - return response; - } - - // Either transcode to FLAC (lossless) or ignore file - if (file.ffProbeData.streams.filter( - (x) => x.codec_type.toLowerCase() === 'audio' && x.codec_name.toLowerCase() === 'alac', - ).length) { - response.processFile = true; - response.infoLog += '☒Found ALAC codec!\n'; - return response; - } - response.infoLog += '☑No ALAC codec found!\n'; - return response; - } - - module.exports.details = details; - module.exports.plugin = plugin; From f94a913f00464bb6203105b9f83f499da59016e9 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Sun, 10 Apr 2022 16:00:42 +0100 Subject: [PATCH 6/7] Fix checkPlugins/lint errors --- .../Tdarr_Plugin_fu69_aune_audio_to_flac.js | 132 +++++++++--------- 1 file changed, 67 insertions(+), 65 deletions(-) diff --git a/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js b/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js index ce546cf..cf0064f 100644 --- a/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js +++ b/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js @@ -1,77 +1,79 @@ -function details() { - return { - id: 'Tdarr_Plugin_fu69_aune_audio_to_flac', - Stage: 'Pre-processing', - Name: 'Aune - Audio to FLAC', - Type: 'Audio', - Operation: 'Transcode', - Description: 'This plugin transcodes different audio codecs to FLAC. ' - + 'Leaving the default inputs results in lossless conversion as ALAC and PCM codecs don\'t require transcoding for FLAC. It ignores files that contains video streams and is made for music libraries.\n\n', - Version: '1.00', - Link: 'https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js', - Tags: 'pre-processing,ffmpeg,audio only', - Inputs: [ - { - name: "codecs", - type: 'string', - defaultValue: 'alac,pcm_s16be,pcm_s16le,pcm_s24be,pcm_s24le,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le', - inputUI: { - type: 'text', - }, - tooltip: - `Select the codec(s) (comma seperated) you would like to transcode to FLAC. +const details = () => ({ + id: 'Tdarr_Plugin_fu69_aune_audio_to_flac', + Stage: 'Pre-processing', + Name: 'Aune - Audio to FLAC', + Type: 'Audio', + Operation: 'Transcode', + Description: 'This plugin transcodes different audio codecs to FLAC. ' + + 'Leaving the default inputs results in lossless conversion as ALAC and' + + ' PCM codecs don\'t require transcoding for FLAC. It ignores files that' + + ' contains video streams and is made for music libraries.\n\n', + Version: '1.00', + Tags: 'pre-processing,ffmpeg,audio only', + Inputs: [ + { + name: 'codecs', + type: 'string', + defaultValue: 'alac,pcm_s16be,pcm_s16le,pcm_s24be,pcm_s24le,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le', + inputUI: { + type: 'text', + }, + tooltip: + `Select the codec(s) (comma seperated) you would like to transcode to FLAC. \\nExample:\\n alac \\nExample:\\n alac, pcm_s16be, mp3 \\nExample:\\n alac,pcm_s16be,pcm_s16le,pcm_s24be,pcm_s24le,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le`, - }, - ], - }; + }, + ], +}); + +// eslint-disable-next-line no-unused-vars +const plugin = (file, librarySettings, inputs, otherArguments) => { + const lib = require('../methods/lib')(); + // eslint-disable-next-line no-unused-vars,no-param-reassign + inputs = lib.loadDefaultValues(inputs, details); + + const response = { + processFile: false, + preset: ' -c:a flac -f flac', + container: '.flac', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '', + }; + + if (inputs.codecs === '' || inputs.codecs === undefined) { + response.infoLog += '☒No codecs selected!\n'; + return response; } - - // eslint-disable-next-line no-unused-vars - function plugin(file, librarySettings, inputs, otherArguments) { - const lib = require('../methods/lib')(); - // eslint-disable-next-line no-unused-vars,no-param-reassign - inputs = lib.loadDefaultValues(inputs, details); + // eslint-disable-next-line no-param-reassign + inputs.codecs = inputs.codecs.split(','); - if (inputs.codecs == "" || inputs.codecs == "undefined") { - response.infoLog += '☒No codecs selected!\n'; - return response; - } else { - inputs.codecs = inputs.codecs.split(","); - } + if (file.ffProbeData.streams.filter((x) => x.codec_type === 'video' && x.avg_frame_rate !== '0/0').length) { + response.infoLog += '☒File contains video!\n'; + return response; + } - const response = { - processFile: false, - preset: ' -c:a flac -f flac', - container: '.flac', - handBrakeMode: false, - FFmpegMode: true, - reQueueAfter: true, - infoLog: '', - }; - - if (file.ffProbeData.streams.filter((x) => x.codec_type === 'video' && x.avg_frame_rate !== '0/0').length) { - response.infoLog += '☒File contains video!\n'; - return response; - } - - // Either transcode to FLAC or ignore file - for(var i = 0; i < file.ffProbeData.streams.length; i++) { - for(var j = 0; j < inputs.codecs.length; j++) { - if(file.ffProbeData.streams[i].codec_type === 'audio' && file.ffProbeData.streams[i].codec_name.toLowerCase() === inputs.codecs[j].toLowerCase().trim()) { - response.processFile = true; - response.infoLog += '☒Found ' + inputs.codecs[j].toLowerCase().trim() + ' codec!\n'; - return response; - } + // Either transcode to FLAC or ignore file + for (let i = 0; i < file.ffProbeData.streams.length; i += 1) { + for (let j = 0; j < inputs.codecs.length; j += 1) { + if ( + file.ffProbeData.streams[i].codec_type === 'audio' + && file.ffProbeData.streams[i].codec_name.toLowerCase() === inputs.codecs[j].toLowerCase().trim() + ) { + response.processFile = true; + response.infoLog += `☒Found ${inputs.codecs[j].toLowerCase().trim()} codec!\n`; + return response; } } - response.infoLog += '☑No matching codecs found!\n'; - return response; } - - module.exports.details = details; - module.exports.plugin = plugin; + response.infoLog += '☑No matching codecs found!\n'; + return response; +}; + +module.exports.details = details; +module.exports.plugin = plugin; From 4d06a170a614773c7e40aa247477aadf6700a5fe Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Wed, 25 May 2022 06:56:18 +0100 Subject: [PATCH 7/7] Rename file and add tests --- ...> Tdarr_Plugin_f4k1_aune_audio_to_flac.js} | 2 +- .../Tdarr_Plugin_f4k1_aune_audio_to_flac.js | 85 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) rename Community/{Tdarr_Plugin_fu69_aune_audio_to_flac.js => Tdarr_Plugin_f4k1_aune_audio_to_flac.js} (98%) create mode 100644 tests/Community/Tdarr_Plugin_f4k1_aune_audio_to_flac.js diff --git a/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js b/Community/Tdarr_Plugin_f4k1_aune_audio_to_flac.js similarity index 98% rename from Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js rename to Community/Tdarr_Plugin_f4k1_aune_audio_to_flac.js index cf0064f..d2632a1 100644 --- a/Community/Tdarr_Plugin_fu69_aune_audio_to_flac.js +++ b/Community/Tdarr_Plugin_f4k1_aune_audio_to_flac.js @@ -1,5 +1,5 @@ const details = () => ({ - id: 'Tdarr_Plugin_fu69_aune_audio_to_flac', + id: 'Tdarr_Plugin_f4k1_aune_audio_to_flac', Stage: 'Pre-processing', Name: 'Aune - Audio to FLAC', Type: 'Audio', diff --git a/tests/Community/Tdarr_Plugin_f4k1_aune_audio_to_flac.js b/tests/Community/Tdarr_Plugin_f4k1_aune_audio_to_flac.js new file mode 100644 index 0000000..20ef026 --- /dev/null +++ b/tests/Community/Tdarr_Plugin_f4k1_aune_audio_to_flac.js @@ -0,0 +1,85 @@ +/* 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: {}, + }, + output: { + processFile: false, + preset: ' -c:a flac -f flac', + container: '.flac', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '☒File contains video!\n', + }, + }, + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleMP3_1.json')), + librarySettings: {}, + inputs: {}, + otherArguments: {}, + }, + output: { + processFile: false, + preset: ' -c:a flac -f flac', + container: '.flac', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '☑No matching codecs found!\n', + }, + }, + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleMP3_1.json')), + librarySettings: {}, + inputs: { + codecs: 'mp3', + }, + otherArguments: {}, + }, + output: { + processFile: true, + preset: ' -c:a flac -f flac', + container: '.flac', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '☒Found mp3 codec!\n', + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_2.json')); + // mock audio file with multiple streams + file.ffProbeData.streams[0].codec_type = 'audio'; + return file; + })(), + librarySettings: {}, + inputs: { + codecs: 'ac3,eac3,aac', + }, + otherArguments: {}, + }, + output: { + processFile: true, + preset: ' -c:a flac -f flac', + container: '.flac', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '☒Found ac3 codec!\n', + }, + }, +]; + +run(tests);