VidiRest.helpers package


VidiRest.helpers.encoding module

VidiRest.helpers.vidispine module

This module contains various helper functions for dealing with data to and from vidispine.

VidiRest.helpers.vidispine.createAutoCompleteRequestDocument(searchquery='', maximum_suggestions=30, field=None)

docstring for createAutoCompleteRequestDocument

VidiRest.helpers.vidispine.createItemSearchDocument(searchquery='', metadata_dict=None, daterange=None, searchcriteria=None, sortlist=None, qdr=None, maximumSuggestions=0, includeDeleted=False)

Given input values from the search page, create a pyxb ItemSearchDocument

includeDelete flag is for setting whether or not we exclude ‘portal_deleted’ items from the results.

VidiRest.helpers.vidispine.createMergedBatchItemMetadataDocument(metadata_document, custom_metadata, update_mode)

This function returns an ItemMetadataDocument to be used in the batch metadata update.

String and text fields are appended with the value in the metadata_document and tags, lookup and checkbox fields are get the new value added to the list of values.

VidiRest.helpers.vidispine.createMetadataDocumentFromDict(_metadata_dict, metadatagroupname=None, vsmetadatafields=None, time_zone=None, encapsulate_in_group=None, start='-INF', end='+INF')

Parameters: * metadata dictionary (from a metadata web form - key = field name, and value = field value) * metadata group name, * metadata fields, in order to fetch the default values/restrictions etc of each field. (UNUSED) * time zone, to format date fields (UNUSED)

Note: The arguments vsmetadatafields and time_zone are not used in this function, kept in for API compatibility.

The result is a proper MetadataDocument pyxb object

VidiRest.helpers.vidispine.createMetadataDocumentFromVSMetadata(_metadata_object, exclude_system=True)

Parameters: * metadata_object - An vidispine metadata structure in json representation

Return: * A MetadataDocumentType which corresponds to metadata_object, possibly excluding some values

VidiRest.helpers.vidispine.createVSMetadataFieldGroupFromDict(_metadata_dict, metadatagroupname=None)

Fakes a VSMetadataFieldGroup from a search form.

This is mainly used to populate the search form with the same data on subsequence requests.

Parameters: * metadata dictionary (from a metadata web form - key = field name, and value = field value) * metadata group name

VidiRest.helpers.vidispine.createVSMetadataFieldGroupFromLibrarySettings(librarySettings, metadatagroup=None)

Fakes a VSMetadataFieldGroup from a library settings document

This is used to create an ItemMetadataElements structure from saved searches and rules engine rules

Parameters: * librarySettings - a library settings document from Vidispine * metadatagroup - the metadata group definition (if not supplied, only the top level metadata will be populated)

VidiRest.helpers.vidispine.formatDate(date_string, time_zone)

Formats the date string to the specific date format that VS expects taking the given time_zone in to consideration


Returns a dict of audio track metadata. The caller should catch in case any of the data is missing.

The datastructure returned has the form:

{ ‘name’: string, E.G “A1”

‘uri’: string, E.G “” ‘language’: string, E.G “eng”


or None in case there are missing values

VidiRest.helpers.vidispine.getMetadataFieldValueTypesFromVSMetadata(fields, exclude_system)

From a fields list in a VSMetadata document, return a list of MetadataFieldValueType fields

VidiRest.helpers.vidispine.getMetadataGroupValueTypesFromVSMetadata(groups, exclude_system)

From a group list in a VSMetadata document, return a list of MetadataGroupValueType


Returns a dict of all subtitles that exists in the metadata.

The datastructure returned has the form:

{ ‘sv’:
{ ‘start’: Timecode,

‘end’: Timecode, ‘text’: string




where the list for each language is sorted by start timecode


Get the title value from a metadata group structure The rule is, item title is the value of the first metatafield in the metadatagroup (order = 1)


Helper function to initiate the API with username and password from config file. Used for debugging purposes.

Reads from config file ‘/etc/cantemo/vidirest/vidirest.config’

VidiRest.helpers.vidispine.getVersion(vsapi, runasuser=None)
VidiRest.helpers.vidispine.removeUnchangedMetadata(new_metadata, old_metadata, ith)

Removed any metadata field from new_metadata that has the same value in the old metadata.


Function to use to reset all rights in the system. Should be used e.g. when the rights of _special_all has been altered

VidiRest.helpers.vidispine.schemaObjectToXML(schemaObject, quote=True)

Helper function used to format pyxb objects to XML for debugging purposes

VidiRest.helpers.vidispine.sort_metadata_fields(fields, field_order=None)

Sort fields by their index in field_order, or name if not found in that list. If sorting fails it’ll return fields in original order.

  • fields – A list of metadata.VSMetadataField objects

  • field_order – What to order the fields on


A ordered list of metadata.VSMetadataField objects

VidiRest.helpers.vidispine.sort_representative_metadata_fields_by_field_order(fields, metadata_group, all_metadata_groups_with_content)

Takes a list of metadata.VSMetadataField objects and sorts them according to field group extradata ‘field_order’ or name if not found in that list.

  • fields (list[metadata.VSMetadataField]) – A list of metadata.VSMetadataField objects

  • metadata_group (str) – A metadata group name.

  • all_metadata_groups_with_content (VidiRest.objects.metadata.VSMetadataGroups) – All metadata groups with content, i.e. result of portal.vidispine.iitem.ItemHelper.getMetadataFieldGroups(content=true), passed in for performance reasons.


A list of sorted metadata.VSMetadataField objects

Return type


Module contents