mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 23:48:15 -07:00
Update flows
This commit is contained in:
parent
658857fdf4
commit
25c4fab8d9
73 changed files with 4295 additions and 839 deletions
|
|
@ -3,17 +3,62 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.plugin = exports.details = void 0;
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Set Video Bitrate',
|
||||
description: 'Set Video Bitrate',
|
||||
name: 'Reorder Streams',
|
||||
description: 'Reorder Streams',
|
||||
style: {
|
||||
borderColor: '#6efefc',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: '',
|
||||
inputs: [],
|
||||
inputs: [
|
||||
{
|
||||
name: 'processOrder',
|
||||
type: 'string',
|
||||
defaultValue: 'codecs,channels,languages,streamTypes',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: "Specify the process order.\nFor example, if 'languages' is first, the streams will be ordered based on that first.\nSo put the most important properties last.\nThe default order is suitable for most people.\n\n \\nExample:\\n\n codecs,channels,languages,streamTypes\n ",
|
||||
},
|
||||
{
|
||||
name: 'languages',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: "Specify the language tags order, separated by commas. Leave blank to disable.\n \\nExample:\\n\n eng,fre\n ",
|
||||
},
|
||||
{
|
||||
name: 'channels',
|
||||
type: 'string',
|
||||
defaultValue: '7.1,5.1,2,1',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: "Specify the channels order, separated by commas. Leave blank to disable.\n \n \\nExample:\\n\n 7.1,5.1,2,1",
|
||||
},
|
||||
{
|
||||
name: 'codecs',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: "Specify the codec order, separated by commas. Leave blank to disable.\n \n \\nExample:\\n\n aac,ac3",
|
||||
},
|
||||
{
|
||||
name: 'streamTypes',
|
||||
type: 'string',
|
||||
defaultValue: 'video,audio,subtitle',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: "Specify the streamTypes order, separated by commas. Leave blank to disable.\n \\nExample:\\n\n video,audio,subtitle\n ",
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
|
|
@ -27,6 +72,96 @@ var plugin = function (args) {
|
|||
var lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
var streams = JSON.parse(JSON.stringify(args.variables.ffmpegCommand.streams));
|
||||
var originalStreams = JSON.stringify(streams);
|
||||
streams.forEach(function (stream, index) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
stream.typeIndex = index;
|
||||
});
|
||||
var sortStreams = function (sortType) {
|
||||
var items = sortType.inputs.split(',');
|
||||
items.reverse();
|
||||
for (var i = 0; i < items.length; i += 1) {
|
||||
var matchedStreams = [];
|
||||
for (var j = 0; j < streams.length; j += 1) {
|
||||
if (String(sortType.getValue(streams[j])) === String(items[i])) {
|
||||
if (streams[j].codec_long_name
|
||||
&& (streams[j].codec_long_name.includes('image')
|
||||
|| streams[j].codec_name.includes('png'))) {
|
||||
// do nothing, ffmpeg bug, doesn't move image streams
|
||||
}
|
||||
else {
|
||||
matchedStreams.push(streams[j]);
|
||||
streams.splice(j, 1);
|
||||
j -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
streams = matchedStreams.concat(streams);
|
||||
}
|
||||
};
|
||||
var processOrder = String(args.inputs.processOrder);
|
||||
var _a = args.inputs, languages = _a.languages, codecs = _a.codecs, channels = _a.channels, streamTypes = _a.streamTypes;
|
||||
var sortTypes = {
|
||||
languages: {
|
||||
getValue: function (stream) {
|
||||
var _a;
|
||||
if ((_a = stream === null || stream === void 0 ? void 0 : stream.tags) === null || _a === void 0 ? void 0 : _a.language) {
|
||||
return stream.tags.language;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
inputs: languages,
|
||||
},
|
||||
codecs: {
|
||||
getValue: function (stream) {
|
||||
try {
|
||||
return stream.codec_name;
|
||||
}
|
||||
catch (err) {
|
||||
// err
|
||||
}
|
||||
return '';
|
||||
},
|
||||
inputs: codecs,
|
||||
},
|
||||
channels: {
|
||||
getValue: function (stream) {
|
||||
var chanMap = {
|
||||
8: '7.1',
|
||||
6: '5.1',
|
||||
2: '2',
|
||||
1: '1',
|
||||
};
|
||||
if ((stream === null || stream === void 0 ? void 0 : stream.channels) && chanMap[stream.channels]) {
|
||||
return chanMap[stream.channels];
|
||||
}
|
||||
return '';
|
||||
},
|
||||
inputs: channels,
|
||||
},
|
||||
streamTypes: {
|
||||
getValue: function (stream) {
|
||||
if (stream.codec_type) {
|
||||
return stream.codec_type;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
inputs: streamTypes,
|
||||
},
|
||||
};
|
||||
var processOrderArr = processOrder.split(',');
|
||||
for (var k = 0; k < processOrderArr.length; k += 1) {
|
||||
if (sortTypes[processOrderArr[k]] && sortTypes[processOrderArr[k]].inputs) {
|
||||
sortStreams(sortTypes[processOrderArr[k]]);
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(streams) !== originalStreams) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
args.variables.ffmpegCommand.shouldProcess = true;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
args.variables.ffmpegCommand.streams = streams;
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue