Media processing script
This is an example of a Media processing web script, which is executed every time an asset is processed by the respective worker (for example, when a new asset is uploaded or when an asset rendition is refreshed). It extracts the metadata properties from the context and adds them to the asset.
Script
Script explanation
This section steps through the script in execution order, explaining each part. The numbered items describe the sequence, not instructions to perform.
-
Include the libraries to be used in the script.
-
Get the
MasterFilerelation of the asset. -
Check if the current file is the master file. Only this metadata is to be copied if this is the case.
-
Create a method that checks whether the property already has commas and escapes them with quotation marks.
-
Convert the metadata headers to csv.
-
Convert the metadata values to csv.
-
Get the metadata property field of the asset.
-
Store the metadata on the asset.
-
Save the asset.
Setup
-
Create a string property called
Metadataon theM.Assetdefinition, setting thecontent typetoMultiple lines. -
Create, publish, and enable a metadata processing script.