Scripting
Reading time ~2 minutes
Cinegy Convert supports automatic execution of PowerShell scripts for various specific cases.
Press the button in the "Pre-processing" field of the profile configuration window. The script will be applied before the task processing:

The following dialog appears:

Press the "Import" button to select an existing PowerShell script from the "Import script from" dialog that appears. |
The script will be loaded to the dialog. You can edit it directly via the keyboard, if necessary:

The currently loaded script can be saved as a PS1 file by pressing the "Export" button and defining its location and name in the "Export script as" dialog that appears. |
Press "OK".
You can also apply a script to be executed when the task processing is finished in the same way by pressing the in the "Post-processing" field.
With the script(s) applied, the field value(s) in the profile editing form will be changed correspondingly:

To expel a selected script, click and select the "Clear" command:

Examples
Pre-processing Scripting
Pre-processing script will be executed prior to the task processing start. It is used for defining additional metadata for a task, for instance, scan the file, calculate the MD5 hash value and locate it into one of the macros, which can be further used in profiles, for example when importing into the Cinegy Archive database.
A sample script provided by Cinegy for download from Github enables generating TrafficID by a certain pattern.
Pre-processing scripting allows adding {src.meta.*} fields and their values in order to generate additional metadata to be applied for the media.
Important
|
Refer to the Source Macros article to get more information on the supported macros and their usage. |
The script sample that demonstrates the required syntax is provided below:
param([Cinegy.Media.Linker.Strategies.ScriptOptimizationProvider]$provider)
$provider.AddMetadata('test_key', 'test1'); //Adding new value
$meta_value = $provider.Metadata['test_key']; //Reading of the added value
$provider.AddMetadata('test_key', 'test2'); //Exception will be generated
$provider.AddMetadata('src.name', 'new_name'); //Exception will be generated
The example above shows that the new metadata generated during the pre-processing script execution can be registered using $provider.AddMetadata(<macro>', $value)
. Once registered, the new metadata can be referenced, for example, in the profile parameters:

Note
|
On the attempt to override the existing metadata values, the exception will occur. |
Post-processing Scripting
Post-processing script will be applied on the entire completion of task processing, once the file is created or node is registered in the Cinegy Archive database.
A sample script provided by Cinegy for download from Github uploads the video file processed by Cinegy Convert on Facebook.
Important
|
More information about this particular case can be found in the post on Cinegy TechCon 2017 presentation "Hacking Cinegy" |