ExifTool - Metadate mapping example
censhare uses ExifTool to extract the metada ta of files.
Steps
- Install the ExifTool. For more information, see this http://www.sno.phy.queensu.ca/~phil/exiftool/
See the result of the ExifTool as XML in the censhare Client, if the logging of “MetaData Mapper” is enabled. A result like this can be found in the XML logging.
XML<data> <assets> <asset id=“” ...> </assets> <local-exiftool> <asset id="216253"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description et:toolkit="Image::ExifTool 9.20"> <ExifTool:ExifToolVersion> 9.20 </ExifTool:ExifToolVersion> <System:FileName> 02 Happy Loop.mp3 </System:FileName> ...
- Or execute the following command to see the results:
exiftool -X filename
Attached is a small AppleScript, that executes a local installed Exiftool, if files are dragged to it. The results are stored as XML documents in the same folder with a “-exiftool.xml” extension.
The mapping of the metadata is done in JavaScript on the Server in the “Import file metadata mapping (JavaScript)” in the module “Asset Management”. Easy mappings (value of an XML element should be stored as an asset feature) can be done in a section starting with this description.
/*
The feature tree contains the following properties:
key:
Key of censhare feature
Mandatory.
type:
Possible values include:
string: parses a string
int: parses an integer
double: parses a double
date: parses a date
array: parses an array
map: of a retrieved key a value is evaluated from a map of fixed key/value map
flash: special handler for evaluating flash usage
childFeatures:
Child features of a hierarchical feature
sources:
Array of XPath expressions to retrieve values from ExifTool output
The order is important: first found value is used
field:
Retrieved value is also written into named field of asset table
mapping:
A fixed key / value map. The key is retrieved from the ExifTool output, the value is used as feature value
default:
If no value is retrieved from a mapping, a default will be used instead
*/
This is a JSON structure and defines in which hierarchy the asset features should be created for the defined values.
Example
The value in the XML of ExifTool:
<ID3v2_3:Title>
Happy Loop
</ID3v2_3:Title>
It should be mapped to a feature with key "test:title". So please add a new JSON item:
{
"key": “test:title",
"type": "string",
"sources": [
"ID3v2_3:Title"
]
}
All other cases (mapping to an asset attribute, values must be changed, …) have to be defined in the corresponding JavaScript. There are a lot of helper functions and a lot of examples in JavaScript.