Tdarr_Plugins icon indicating copy to clipboard operation
Tdarr_Plugins copied to clipboard

Flow Plugin - RemoveStreamByProperty: Codec-Type Filtering & Fix for 'not_includes

Open pavax opened this issue 8 months ago • 1 comments

Problem 1: I have extended the RemoveStreamByProperty FlowPlugin to allow specifying the codec type (audio, video, subtitle or any).

The new default value for the new property is set to any so that my change is backwards compatible.

Use Case: In my workflow, I need to ensure that audio streams matching a specific language property are removed before encoding them. Previously, the plugin would also remove video streams if their language matched, which was unintended. This update ensures only the specified codec type is affected.

Problem 2: Fixes: https://github.com/HaveAGitGat/Tdarr_Plugins/issues/804

I also fixed an issue when using the not_includes option.

Example Scenario:

Consider the following audio tracks:

  • Track 1: en
  • Track 2: de
  • Track 3: it

Plugin Configuration:

  • Condition: not_includes
  • Property to check: tags.language
  • Values to remove: de, en, ger, eng, und

Expected Result:

  • Track 3 (it) should be removed because it does not match any of the specified values.

Current (Bugged) Behavior:

  • Instead of removing only Track 3, all streams are removed.
Root Cause:

The issue occurs because the code incorrectly iterates over each "value to remove" individually. If a single value does not match the property, the stream is immediately marked for removal, leading to unintended removals.

My Fix:

My fix changes this so that the plugins behave as follows:

  • For includes → Remove the stream if the "Property to check" contains ANY of the "values to remove".
  • For not_includes → Remove the stream if the "Property to check" contains NONE of the "values to remove".

Additionally, my fix improves the logging, so that not multiple logs are printed for multiple values and improves the iteration-efficiency a bit as I use the .some() method which stops as soon as a match was found.

pavax avatar Mar 02 '25 20:03 pavax