mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 07:29:04 -07:00
Rename plugin, throw error if no video streams found
This commit is contained in:
parent
491e40b885
commit
6af54253ba
2 changed files with 21 additions and 11 deletions
|
|
@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.plugin = exports.details = void 0;
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Check Multiple Video Streams',
|
||||
description: 'This plugin checks if an input file has more than one video stream.',
|
||||
name: 'Check Video Streams Count',
|
||||
description: 'This plugin checks if the number of video streams is 1 or more.',
|
||||
style: {
|
||||
borderColor: 'orange',
|
||||
},
|
||||
|
|
@ -32,14 +32,20 @@ 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 outputNumber = 2; // Default to 'Special case' (> 1 video tracks)
|
||||
var ffProbeData = args.inputFileObj.ffProbeData;
|
||||
if (!ffProbeData || !ffProbeData.streams) {
|
||||
throw new Error('ffProbeData or ffProbeData.streams is not available.');
|
||||
}
|
||||
var videoStreams = ffProbeData.streams.filter(function (stream) { return stream.codec_type === 'video'; }).length;
|
||||
if (videoStreams === 1) {
|
||||
outputNumber = 1; // 'Success' (has exactly one video stream)
|
||||
var outputNumber = 1; // Default to one video stream
|
||||
if (videoStreams === 0) {
|
||||
throw new Error('No video streams found in file.');
|
||||
}
|
||||
else if (videoStreams === 1) {
|
||||
outputNumber = 1; // One video stream
|
||||
}
|
||||
else if (videoStreams > 1) {
|
||||
outputNumber = 3; // More than one video stream
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
|
|
@ -6,8 +6,8 @@ import {
|
|||
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
const details = (): IpluginDetails => ({
|
||||
name: 'Check Multiple Video Streams',
|
||||
description: 'This plugin checks if an input file has more than one video stream.',
|
||||
name: 'Check Video Streams Count',
|
||||
description: 'This plugin checks if the number of video streams is 1 or more.',
|
||||
style: {
|
||||
borderColor: 'orange',
|
||||
},
|
||||
|
|
@ -36,8 +36,6 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
|
||||
let outputNumber = 2; // Default to 'Special case' (> 1 video tracks)
|
||||
|
||||
const { ffProbeData } = args.inputFileObj;
|
||||
|
||||
if (!ffProbeData || !ffProbeData.streams) {
|
||||
|
|
@ -46,8 +44,14 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
|
|||
|
||||
const videoStreams = ffProbeData.streams.filter((stream) => stream.codec_type === 'video').length;
|
||||
|
||||
if (videoStreams === 1) {
|
||||
outputNumber = 1; // 'Success' (has exactly one video stream)
|
||||
let outputNumber = 1; // Default to one video stream
|
||||
|
||||
if (videoStreams === 0) {
|
||||
throw new Error('No video streams found in file.');
|
||||
} else if (videoStreams === 1) {
|
||||
outputNumber = 1; // One video stream
|
||||
} else if (videoStreams > 1) {
|
||||
outputNumber = 2; // More than one video stream
|
||||
}
|
||||
|
||||
return {
|
||||
Loading…
Add table
Add a link
Reference in a new issue