Migz Plugins

1. Made changes to all plugins following lint testing. There are still various warnings/errors but my very limited knowledge of javascript means I just don't understand what the errors mean. Or in some cases I don't understand how to split the variable across several lines to confirm to the line limits.
I did manage to get it from
952 problems (943 errors, 9 warnings)
down to
37 problems (28 errors, 9 warnings)

2. Fix Flawed logic in FFMPEG plugins which would cause remux conditions to never trigger. Was checking if file was HEVC & VP9 which is impossible as they're both codecs.

3. Fixed a bug with CleanTitle where plugin would fail if a stream in the file didn't have a title.

4. Modify CleanSubtitle plugin to not remove sdh subtitles.

5. Include new plugin to just perform remuxes. Mainly aimed at remuxing to mkv or mp4.
This commit is contained in:
Migz93 2020-12-14 17:33:17 +00:00
parent e9370ffe7c
commit 864cf41f1d
10 changed files with 1136 additions and 882 deletions

View file

@ -1,68 +1,68 @@
/* eslint-disable */
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
function details() {
return {
id: "Tdarr_Plugin_MC93_MigzImageRemoval",
Stage: "Pre-processing",
Name: "Migz-Remove image formats from file",
Type: "Video",
Operation: "Clean",
Description: `Identify any unwanted image formats in the file and remove those streams. MJPEG & PNG \n\n`,
Version: "1.2",
id: 'Tdarr_Plugin_MC93_MigzImageRemoval',
Stage: 'Pre-processing',
Name: 'Migz-Remove image formats from file',
Type: 'Video',
Operation: 'Clean',
Description: 'Identify any unwanted image formats in the file and remove those streams. MJPEG & PNG \n\n',
Version: '1.3',
Link:
"https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_MigzImageRemoval.js",
Tags: "pre-processing,ffmpeg,video only",
'https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_MigzImageRemoval.js',
Tags: 'pre-processing,ffmpeg,video only',
};
}
function plugin(file, librarySettings, inputs) {
var response = {
function plugin(file, librarySettings) {
const response = {
processFile: false,
preset: "",
preset: '',
handBrakeMode: false,
container: "." + file.container,
container: `.${file.container}`,
FFmpegMode: true,
reQueueAfter: true,
infoLog: "",
infoLog: '',
};
// Check if file is a video. If it isn't then exit plugin.
if (file.fileMedium !== "video") {
if (file.fileMedium !== 'video') {
response.processFile = false;
response.infoLog += "☒File is not a video. \n";
response.infoLog += '☒File is not a video. \n';
return response;
}
// Set up required variables.
var videoIdx = 0;
var extraArguments = "";
var convert = false;
let videoIdx = 0;
let extraArguments = '';
let convert = false;
// Go through each stream in the file.
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
for (let i = 0; i < file.ffProbeData.streams.length; i++) {
// Check if stream is video.
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "video") {
if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'video') {
// Check if stream codec is mjpeg or png. Remove if so.
if (
file.ffProbeData.streams[i].codec_name == "mjpeg" ||
file.ffProbeData.streams[i].codec_name == "png"
file.ffProbeData.streams[i].codec_name === 'mjpeg'
|| file.ffProbeData.streams[i].codec_name === 'png'
) {
convert = true;
extraArguments += `-map -v:${videoIdx} `;
}
// Increment videoIdx.
videoIdx++;
videoIdx += 1;
}
}
// Convert file if convert variable is set to true.
if (convert === true) {
response.preset += `,-map 0 -c copy -max_muxing_queue_size 9999 ${extraArguments}`;
response.infoLog += `☒File has image format stream, removing. \n`;
response.infoLog += '☒File has image format stream, removing. \n';
response.processFile = true;
} else {
response.processFile = false;
response.infoLog +=
"☑File doesn't contain any unwanted image format streams.\n";
response.infoLog
+= "☑File doesn't contain any unwanted image format streams.\n";
}
return response;
}