Skip to content

Custom Functions

Michael Higgins edited this page Nov 23, 2022 · 14 revisions

Run Custom Code

File location is ./config/custom.py

Sample is located in ./setup/custom.py.sample

Methods

  • validation
  • blockVideoCopy
  • blockAudioCopy
  • skipStream
  • skipUA
  • streamTitle

Params for validation

  • MediaProcessor object mp
  • MediaInfo object info
  • String path to file inputfile
  • Metadata metadata object tagdata

Return value should be a bool. True is file should be considered valid, false to reject. File still may be rejected if it fails other checks in the analysis

Tip

The validation method can also be used to intercept the script settings object and make changes to your settings based on conditionals. The mp.settings object is an instance of ReadSettings and will be passed on when the generateOptions method is called so changes you make here will carry through. This is a good option if you have complex conditions where you'll want to use alternate settings. You could in theory here create a whole new ReadSettings instance with an alternate autoProcess.ini file if desired

Params for blockVideoCopy and blockAudioCopy

  • MediaProcessor object mp
  • MediaStreamInfo object stream
  • String path to file inputfile

Return value should be a bool. True if you want to block the stream from being copied, false to continue with normal script operation. Stream may not be copied if it fails other checks in the analysis.

Params for skipStream and skipUA

  • MediaProcessor object mp
  • MediaStreamInfo object stream
  • MediaInfo object info
  • String path to file inputfile
  • Metadata metadata object tagdata

Return value should be a bool. True if you want to skip the source stream either entirely for skipStream or just for the purposes of creating a universal audio track for skipUA.

Params for streamTitle

  • MediaProcessor object mp
  • MediaStreamInfo object stream
  • Dict object containing target options for output options
  • Bool subtitle is image based for subtitle stream imageBased
  • String path to external subtitle file is applicable path
  • Metadata metadata object tagdata

Return value should be a string which will be used as the new stream title or None. None will fall back to the script default methods for determining stream title. If you want to set a blank title return an empty string ""