mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-13 17:30:27 -07:00
Add exactMatch option to property filters
This commit is contained in:
parent
c00dfa7d9e
commit
62ef9e7ad8
5 changed files with 109 additions and 15 deletions
|
|
@ -1,3 +1,5 @@
|
|||
const { strHasValue } = require('../methods/utils');
|
||||
|
||||
const details = () => ({
|
||||
id: 'Tdarr_Plugin_00td_filter_by_file_property',
|
||||
Stage: 'Pre-processing',
|
||||
|
|
@ -31,6 +33,21 @@ const details = () => ({
|
|||
tooltip:
|
||||
'Enter a comma separated list of values to check for.',
|
||||
},
|
||||
{
|
||||
name: 'exactMatch',
|
||||
type: 'boolean',
|
||||
defaultValue: 'true',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'false',
|
||||
'true',
|
||||
],
|
||||
},
|
||||
tooltip:
|
||||
'Specify true if the property value must be an exact match,'
|
||||
+ ' false if the property value must contain the value.',
|
||||
},
|
||||
{
|
||||
name: 'continueIfPropertyFound',
|
||||
type: 'boolean',
|
||||
|
|
@ -72,19 +89,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
|
||||
const propertyValues = inputs.propertyValues.trim().split(',');
|
||||
|
||||
let fileContainsProperty = false;
|
||||
try {
|
||||
for (let i = 0; i < propertyValues.length; i += 1) {
|
||||
try {
|
||||
if (file[propertyName].includes(propertyValues[i])) {
|
||||
fileContainsProperty = true;
|
||||
break;
|
||||
}
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
const fileContainsProperty = strHasValue(propertyValues, file[propertyName], inputs.exactMatch);
|
||||
|
||||
const message = `File property ${propertyName} of ${file[propertyName]}`
|
||||
+ ` being one of ${propertyValues.join(',')} has`;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
const { strHasValue } = require('../methods/utils');
|
||||
|
||||
const details = () => ({
|
||||
id: 'Tdarr_Plugin_00td_filter_by_stream_tag',
|
||||
Stage: 'Pre-processing',
|
||||
|
|
@ -31,6 +33,21 @@ const details = () => ({
|
|||
tooltip:
|
||||
'Enter a comma separated list of tag values to check for.',
|
||||
},
|
||||
{
|
||||
name: 'exactMatch',
|
||||
type: 'boolean',
|
||||
defaultValue: 'true',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'false',
|
||||
'true',
|
||||
],
|
||||
},
|
||||
tooltip:
|
||||
'Specify true if the property value must be an exact match,'
|
||||
+ ' false if the property value must contain the value.',
|
||||
},
|
||||
{
|
||||
name: 'continueIfTagFound',
|
||||
type: 'boolean',
|
||||
|
|
@ -76,12 +93,14 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
try {
|
||||
try {
|
||||
for (let i = 0; i < file.ffProbeData.streams.length; i += 1) {
|
||||
if (tagValues.includes(file.ffProbeData.streams[i]?.tags[tagName])) {
|
||||
if (strHasValue(tagValues, file.ffProbeData.streams[i]?.tags[tagName], inputs.exactMatch)) {
|
||||
streamContainsTag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
// err
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
const message = `A stream with tag name ${tagName} containing ${tagValues.join(',')} has`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue