parent
84189d5cfe
commit
36e21d1b6a
@ -1,80 +1,48 @@
|
|||||||
function details() {
|
function details() {
|
||||||
return {
|
return {
|
||||||
id: "Tdarr_Plugin_fu72_aune_alac_to_flac",
|
id: 'Tdarr_Plugin_fu72_aune_alac_to_flac',
|
||||||
Stage: "Pre-processing",
|
Stage: 'Pre-processing',
|
||||||
Name: "Aune - ALAC to Flac",
|
Name: 'Aune - ALAC to Flac',
|
||||||
Type: "Audio",
|
Type: 'Audio',
|
||||||
Operation: "Transcode",
|
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`,
|
Description: '[Contains built-in filter] This plugin transcodes all ALAC-tracks to FLAC. '
|
||||||
Version: "1.00",
|
+ 'It ignores files that contains video streams and is made for music libraries.\n\n',
|
||||||
Link: "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_fu72_aune_alac_to_flac.js",
|
Version: '1.00',
|
||||||
Tags: "pre-processing,ffmpeg,audio only",
|
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) {
|
// eslint-disable-next-line no-unused-vars
|
||||||
//Must return this object
|
function plugin(file, librarySettings, inputs, otherArguments) {
|
||||||
|
const lib = require('../methods/lib')();
|
||||||
var response = {
|
// eslint-disable-next-line no-unused-vars,no-param-reassign
|
||||||
|
inputs = lib.loadDefaultValues(inputs, details);
|
||||||
|
const response = {
|
||||||
processFile: false,
|
processFile: false,
|
||||||
preset: "",
|
preset: '<io> -f flac',
|
||||||
container: "." + file.container,
|
container: '.flac',
|
||||||
handBrakeMode: false,
|
handBrakeMode: false,
|
||||||
FFmpegMode: false,
|
FFmpegMode: true,
|
||||||
reQueueAfter: false,
|
reQueueAfter: true,
|
||||||
infoLog: "",
|
infoLog: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mark video as false
|
if (file.ffProbeData.streams.filter((x) => x.codec_type === 'video').length) {
|
||||||
var video = false;
|
response.infoLog += '☒File contains video!\n';
|
||||||
// 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;
|
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
|
// Either transcode to FLAC (lossless) or ignore file
|
||||||
if(transcode) {
|
if (file.ffProbeData.streams.filter(
|
||||||
|
(x) => x.codec_type.toLowerCase() === 'audio' && x.codec_name.toLowerCase() === 'alac',
|
||||||
|
).length) {
|
||||||
response.processFile = true;
|
response.processFile = true;
|
||||||
response.preset = ", -f flac";
|
response.infoLog += '☒Found ALAC codec!\n';
|
||||||
response.container = ".flac";
|
|
||||||
response.handBrakeMode = false;
|
|
||||||
response.FFmpegMode = true;
|
|
||||||
response.reQueueAfter = true;
|
|
||||||
response.infoLog += "☒Found ALAC codec!\n";
|
|
||||||
return response;
|
return response;
|
||||||
} else {
|
|
||||||
response.processFile = false;
|
|
||||||
response.infoLog += "☑No ALAC codec found!\n";
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
response.infoLog += '☑No ALAC codec found!\n';
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.details = details;
|
module.exports.details = details;
|
||||||
|
|||||||
Loading…
Reference in new issue